我在/etc/nginx/sites-available/default
. 结果,我的网站http://www.funfun.ink/1/#/home可以重定向到 https://www.funfun.ink/1/#/home并且加载良好。
但我不确定proxy_pass http://localhost:3000
配置是否正确,请注意我希望整个网站始终使用 SSL。我试过proxy_pass https://localhost:3000
and proxy_pass https://127.0.0.1:3000
(在我的另一个网站和服务器上工作),但http://www.funfun.ink/1/#/home总是导致502 bad gateway
.
谁能告诉我 1)为什么proxy_pass https://127.0.0.1:3000
导致502 bad gateway
;2)proxy_pass http://localhost:3000
关于 SSL 的配置是否正确,尽管结果看起来不错?
server {
listen 80;
server_name funfun.ink www.funfun.ink;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl;
server_name funfun.ink www.funfun.ink;
ssl_certificate /etc/nginx/cert/1530230026231.pem;
ssl_certificate_key /etc/nginx/cert/1530230026231.key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
ssl_dhparam /etc/ssl/certs/dhparam.pem;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_session_timeout 1d;
ssl_stapling on;
ssl_stapling_verify on;
add_header Strict-Transport-Security max-age=15768000;
location ~* ^/\b(?!1|js|socket.io|monaco-editor|libs|dist|fonts|javascripts|formatter|ui|css|stylesheets|htmls|imgs|static|httpOnly|tmp|uploads)\w+\b/? {
rewrite .* /1/#$request_uri redirect;
}
location ~* ^/1/\b(?!#|auth)\w+\b/? {
rewrite ^/1/(.*[.]js)$ https://www.funfun.ink/dist/$1 redirect;
rewrite ^/1/(.*[^.][^j][^s])$ https://www.funfun.ink/1/#/$1 redirect;
}
location = / {
return 301 /home;
}
location ~ /.well-known {
allow all;
}
location / {
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Accept-Encoding "";
proxy_set_header Proxy "";
# proxy_pass https://127.0.0.1:3000;
# proxy_pass https://localhost:3000;
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}