✅ Can't get HTTPS to work for my api deployment.
I am following the Microsoft docs https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/linux-nginx?view=aspnetcore-9.0&tabs=linux-ubuntu step by step and I get the point where you set up nginx everything works when I'm on http, but the second i try to make anything go to https everything breaks, the connections time out and I can't get anything to work, I have no idea why.
No working HTTPS
server {
listen 80;
server_name questbound.xyz www.questbound.xyz;
# Redirect all HTTP traffic to HTTPS
return 301 https://$host$request_uri;
}
server {
listen 443 ssl;
server_name questbound.xyz www.questbound.xyz;
# SSL Configuration
ssl_certificate /etc/letsencrypt/live/questbound.xyz/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/questbound.xyz/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
# Proxy to your backend API
location / {
proxy_pass http://0.0.0.0:5000; # Ensure the API is running here
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;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
server {
listen 80;
server_name questbound.xyz www.questbound.xyz;
# Redirect all HTTP traffic to HTTPS
return 301 https://$host$request_uri;
}
server {
listen 443 ssl;
server_name questbound.xyz www.questbound.xyz;
# SSL Configuration
ssl_certificate /etc/letsencrypt/live/questbound.xyz/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/questbound.xyz/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
# Proxy to your backend API
location / {
proxy_pass http://0.0.0.0:5000; # Ensure the API is running here
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;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
1 Reply
Working HTTP
server {
listen 80;
server_name questbound.xyz www.questbound.xyz;
# SSL Configuration
ssl_certificate /etc/letsencrypt/live/questbound.xyz/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/questbound.xyz/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
# Proxy to your backend API
location / {
proxy_pass http://0.0.0.0:5000; # Ensure the API is running here
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;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
server {
listen 80;
server_name questbound.xyz www.questbound.xyz;
# SSL Configuration
ssl_certificate /etc/letsencrypt/live/questbound.xyz/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/questbound.xyz/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
# Proxy to your backend API
location / {
proxy_pass http://0.0.0.0:5000; # Ensure the API is running here
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;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}