This is my first setup with nginx and I'm using it to proxy to nodejs. HTTP is on port 3000, and HTTPS is on port 3001.
If I go to http://test.domain.com it loads the regular unsecure pages. If I go to https://test.domain.com it loads the secure pages. But I want it to redirect from non-https to https.
What's wrong with my config? This is the whole domain.conf file I'm using.
server {
listen 80;
server_name test.domain.com
return 301 https://test.domain.com$request_uri;
}
server {
listen 443 ssl;
server_name test.domain.com;
ssl_certificate /etc/nginx/ssl/domain.crt;
ssl_certificate_key /etc/nginx/ssl/server.key;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header HOST $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_pass https://127.0.0.1:3001;
proxy_redirect off;
}
}
I have restarted nginx multiple times.
Thanks!