nginx refuxing connection SSL

I have a site that I am trying to get SSL working on. This is my first time ever doing so.

My server config looks something like:

   server {
      listen 80 ssl;
      server_name {site_name};

      include /etc/nginx/include.d/ssl-common;

      location / {
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header Host $http_host;
        proxy_pass https://{my_server_ip}:8001;
      }
    }

where the ssl-common file looks like:

    ssl_certificate /etc/nginx/ssl/server.crt;
    ssl_certificate_key /etc/nginx/ssl/server.key;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers ECDHE-RSA-AES128-SHA256:AES128-GCM-SHA256:RC4:HIGH:!MD5:!aNULL:!EDH;
    ssl_prefer_server_ciphers on;

The certificate is self-signed (is this the issue?).

When I go to my webpage, I get a connection_refused message. No errors show in the nginx logs.

Thanks

Answer

listen 80 ssl;

Port 80 is for HTTP. Port 443 is for HTTPS. This should be like:

listen 80;
listen 443 ssl;

As it is, your browser is probably trying to make a connection to port 443, as it should. Since Nginx is erroneously listening on port 80 instead, the connection is refused.

Attribution
Source : Link , Question Author : Aakash Shah , Answer Author : Matt Nordhoff

Leave a Comment