skip to Main Content

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;
    }

2

Answers


  1. Chosen as BEST ANSWER

    Oops, i just realized i needed to add this in the https section.

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

    hehe


  2. 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;
         }
     
        ...
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search