I have the following nginx blocks in /etc/nginx/sites-available/default
. As a result, my website http://www.funfun.ink/1/#/home can be redirected to https://www.funfun.ink/1/#/home and loads well.
But I'm not sure if proxy_pass http://localhost:3000
is the right configuration, note that I want the whole website to always use SSL. I tried proxy_pass https://localhost:3000
and proxy_pass https://127.0.0.1:3000
(which worked in another website and server of mine), but http://www.funfun.ink/1/#/home always led to 502 bad gateway
.
Could anyone tell me 1) why proxy_pass https://127.0.0.1:3000
led to 502 bad gateway
; 2) is proxy_pass http://localhost:3000
the right configuration with regards to SSL, though the result looks good?
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";
}
}