SSL configuration on nginx 1.6

2020-04-17 12:58发布

I'm tryng to configure nginx 1.6 on a VM to accept https connection. I have created a self signed certificate following this tutorial. and then I have added a configuration file like this

server {
    listen       443 ssl;
    server_name  localhost;

    ssl_certificate      /etc/nginx/ssl/nginx.crt;
    ssl_certificate_key  /etc/nginx/ssl/nginx.key;

    ssl_session_cache shared:SSL:1m;
    ssl_session_timeout  5m;

    ssl_ciphers  HIGH:!aNULL:!MD5;
    ssl_prefer_server_ciphers   on;

    location / {
        root   /usr/share/nginx/html;
        index  index.html index.htm;
    }
}

The problem is that when I access the https url from the browser I have no results but this error

Error code: ERR_CONNECTION_RESET

I think that port 443 is open

netstat -tulpn | grep 443
tcp        0      0 0.0.0.0:443             0.0.0.0:*               LISTEN      8603/nginx.conf

Moreover, I can wget the index.html:

wget -–no-check-certificate  https://<server_url>

Now, I suppose that the problem is the untrusted certificate because wget gives error if -–no-check-certificate is omitted but in this case I expect browser (Chrome or Firefox) to give some kind of warning and maybe let me see the untrusted certificate instead of reset connection. What am I doing wrong? Thanks in advance

EDIT:

Firefox gives "200 Connection Established" but no content or warning is shown. It only says that connection has been canceled

2条回答
来,给爷笑一个
2楼-- · 2020-04-17 13:15

Issue was on my side renamed my.host.com to localhost and it worked.

server_name localhost;

查看更多
聊天终结者
3楼-- · 2020-04-17 13:39

The problem might be with the certificate. You can see tutorial to create *.pem certificate instead of *.crt and add as:

ssl_certificate      /etc/nginx/ssl/nginx.pem;
查看更多
登录 后发表回答