Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

你好,请教一下如何把这个项目在服务器中升级为https访问呢? #13

Closed
kozhnpc opened this issue Feb 16, 2020 · 2 comments

Comments

@kozhnpc
Copy link

kozhnpc commented Feb 16, 2020

不太懂node和服务器这块的,见谅,查了不少资料,node js 开启https服务,需要域名、服务器、SSL证书,这些我都有,想请问一下,如何在你这个项目中开启https服务呢?

我看你的这个测试网址也是支持https请求的,所以想请教一下,你的https是在项目中设置的嘛?需要在项目中配置什么呢? 谢谢啦

@jsososo
Copy link
Owner

jsososo commented Feb 16, 2020

项目中是不用配置的,配置nginx 就好了,给你我服务器上的nginx 配置吧,域名和证书存放地址你就根据你自己的情况改一下就好了

# qq 音乐接口
server {
		listen      443 ssl;
    server_name api.qq.jsososo.com;

    client_max_body_size    100m;
    ssl_certificate         /etc/nginx/cert/api.qq.jsososo.com.pem;
    ssl_certificate_key     /etc/nginx/cert/api.qq.jsososo.com.key;

    location  / {
        proxy_pass http://127.0.0.1:3300;
        proxy_set_header Host "api.qq.jsososo.com";
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
}

#http以301状态到https
server {
    listen 80;
    server_name doc.qq.jsososo.com;
    return 301 https://$host$request_uri;
}

@kozhnpc
Copy link
Author

kozhnpc commented Feb 16, 2020

好的,感谢感谢

@kozhnpc kozhnpc closed this as completed Feb 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants