Geoff
Geoff

Reputation: 6649

Nginx ssl with a custom port configuration fails

I have the following nginx configuration

server {
    listen 4050;
    listen 443 ssl;

    server_name url ww.url;

    location / {
     proxy_pass http://localhost:6091;
     proxy_set_header Upgrade $http_upgrade;
     proxy_set_header Connection "upgrade";
     proxy_http_version 1.1;
     proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
     proxy_set_header Host $host;
    }



   ssl_certificate /etc/letsencrypt/live/domain/fullchain.pem; # managed by Certbot
   ssl_certificate_key /etc/letsencrypt/live/domain/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

}

THe above works on http that is after accessing http://domain:4050 but fails when i access the same with https that is via https://domain:4050

What am i missing on this to make it work with https on the port 4050.

Upvotes: 0

Views: 191

Answers (1)

Al-waleed Shihadeh
Al-waleed Shihadeh

Reputation: 2855

to make it work with https, you need to change listen 4050; to listen 4050 ssl;. But then you will not be able to use it with http.

You cant use the same port for both HTTP and HTTPS

Upvotes: 2

Related Questions