Hello, I am trying to redirect my http traffic to https and also proxy_pass to port 5000… i cannot get it to work? what am i doing wrong…?
server {
listen 80;
listen [::]:80;
root /var/www/this/html;
index index.html index.htm index.nginx-debian.html;
server_name example.com www.example.com;
if ($host = www.example.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
if ($host = example.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen [::]:443 ssl ipv6only=on; # managed by Certbot
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
location / {
proxy_pass http://localhost:5000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Hi @andrewlintonfife,
Everything looks perfectly fine from my point of view. Anyway, here is how I usually do such configs. Please give it a try and let me know how it goes :
Remember to change mysite.com with your actual domain! Once you do make the changes, please don’t forget to actually restart Nginx.
Looking forward to your reply
Regards, KFSys