NGINX SSL Connection Refused

被刻印的时光 ゝ 提交于 2020-12-06 07:29:48

问题


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.

来源:https://stackoverflow.com/questions/48230252/nginx-ssl-connection-refused

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!