amazon-web-servicesnginxssl

Nginx keeps showing "welcome to nginx" for https but it's working fine with http


I've browsed through a couple questions here and also did what was recommended from this link: nginx https not working

I have the ssl cert and symlinked my sites-enabled and sites-available. I have also opened port 443.

My app is working fine with http for now as i've not enabled redirect but I still get Welcome to nginx! in HTTPS and it might be because nginx is getting confused with my config file? i'm not sure. below is my config file. Or maybe because of file permissions.

server {
    listen 80;
    listen [::]:80;
    server_name somewebsite.ca www.somewebsite.ca;

    # Redirect
#    return 301 https://$host$request_uri;

    # If you don't want a redirect, remove the return 301 line and include a location block
    access_log /var/log/nginx/reverse-access.log;
    error_log /var/log/nginx/reverse-error.log;
    location / {
         include proxy_params;
         proxy_pass http://127.0.0.1:5000;
     }
    client_max_body_size 300M;
}

# HTTPS Server Block
server {
    listen 443 ssl;
    listen [::]:443 ssl;
    server_name somewebsite.ca;

    ssl_certificate /etc/letsencrypt/live/somewebsite.ca/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/somewebsite.ca/privkey.pem;

    ssl_protocols TLSv1.2 TLSv1.3;
    ssl_prefer_server_ciphers on;
    ssl_ciphers HIGH:!aNULL:!MD5;

    # Location blocks for different services
    location /auth {
        include proxy_params;
        proxy_pass http://127.0.0.1:5000;
    }

    location /camera {
        include proxy_params;
        proxy_pass http://127.0.0.1:5000;
    }

    location /photo {
        include proxy_params;
        proxy_pass http://127.0.0.1:5000;
        proxy_read_timeout 600s;
        proxy_send_timeout 600s;
        client_max_body_size 300M;
    }

Solution

  • you haven't defined location / in https block (listen 443):

    should be

    server {
        listen 443 ssl;
        listen [::]:443 ssl;
        server_name somewebsite.ca;
    
        ...
        
        location / {
             include proxy_params;
             proxy_pass http://127.0.0.1:5000;
         }
     
        ...