2

I have been trying to setup SSL for my Nginx Server for hours now, but it keeps saying "This site can’t be reached. Connection refused" when I visit my page. Without SSL everything works just fine.

My nginx.conf looks like this:

# HTTP SERVER
server {
        server_name  example.com;
        listen 80 default_server;
        listen [::]:80 default_server ipv6only=on;

        # WE USE JUST HTTPS
        location / {
            rewrite ^ https://$http_host$request_uri? permanent;
        }
}

# HTTPS Server
server {
    listen 443;
    server_name example.com;

    ssl on;
    ssl_certificate /etc/nginx/ssl/example.com.crt;        # path to your cacert.pem
    ssl_certificate_key /etc/nginx/ssl/example.com.key;    # path to your privkey.pem

    access_log  /var/log/nginx/client-access.log;
    error_log   /var/log/nginx/client-error.log;

    root /usr/share/nginx/html;
    index index.html index.htm;

    location / {
        try_files $uri $uri/ index.html /index.html;
    }
}

Obviously my server_name is having my correct server name inserted in my file. It would be awesome if someone could help me.

The Nginx server is setup to serve a ReactJS application.

2
  • 2
    Did you do the first checks then we know if the server is really running and reachable locally ? 1/ Check if port 443 is listening (netstat -an) 2/ try to access locally with a curl -kv localhost 3/ If both 1&2 are OK, disable your firewall 1 minute (systemctl stop firewalld on CentOS 7 for example) and check from remote Jan 12, 2018 at 16:43
  • Thanks for your answer! The firewall was the issue.
    – A E
    Jan 12, 2018 at 17:12

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.