Please use this template for troubleshooting questions.
My issue: i have two server blocks, nginx only sees the first one.
How I encountered the problem: have first server block serving port 80 with web contents, then after issuing ssl certificate, change port to 443 and specify ssl certificate on first server block, and create second server block serving port 80 to redirect requests to https.
Solutions I’ve tried:
Version of NGINX or NGINX adjacent software (e.g. NGINX Gateway Fabric): 1.29.2
Deployment environment: Docker v26
Minimal NGINX config to reproduce your issue (preferably running on https://tech-playground.com/playgrounds/nginx for ease of debugging, and if not as a code block): (Tip → Run nginx -T to print your entire NGINX config to your terminal.)
server {
server_name example.com;
listen 443 ssl;
listen [::]:443 ssl;
http2 on;
ssl_certificate /path/to/example.pem;
ssl_certificate_key /path/to/example-privkey.pem;
root /var/www/html;
}
server { # nginx in docker doesn't see any other server blocks besides the very first one.
server_name example.com;
listen 80;
listen [::]:80;
return 301 https://$host$request_uri;
}
NGINX access/error log: (Tip → You can usually find the logs in the /var/log/nginx directory.)