Nginx Reverse Proxy Ssl Error

So I have my Nginx reverse proxy set up as follows.

    listen 80;
    server_name mydomain.net;
    return 301 
    }
server {
    listen 443;
    server_name mydomain.net;

    ssl_certificate           /etc/letsencrypt/live/
    ssl_certificate_key       /etc/letsencrypt/live/

    location / {
       proxy_pass 
    }
}


But when I try to connect to my website it says "This site can't provide a secure connection, ERR_SSL_PROTOCOL_ERROR. Did I misconfigure SSL?

1 Answer

You should change the listen directive to listen with the SSL protocol: listen 80; says to listen for http connections on port 80, but listen 443 ssl; says to listen on port 443 for https connections.

the configuration should be as follows:

server {
    listen 80;
    server_name mydomain.net;
    return 301 
}

server {
    listen 443 ssl;
    server_name mydomain.net;

    ssl_certificate           /etc/letsencrypt/live/
    ssl_certificate_key       /etc/letsencrypt/live/

    location / {
        proxy_pass 
    }
}

you can also combine them. you can remove your return statement, and combine all others into one server block. just add this snippet:

  if ($scheme = http) {
    return 301 
  }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Marcus Vance

Marcus Vance

Cybersecurity & Digital Privacy Researcher

Marcus Vance is a cybersecurity auditor and technology writer dedicated to educating the public about online safety, data privacy regulations, enterprise security, and emerging cyber threats.

Share this article
Twitter Facebook Pinterest