-2

当我尝试使用 ssl 打开我的网站时,我收到错误 ERR_CONNECTION_RESET。

日志中没有信息。

防火墙中的 443 端口是开放的。在 http 上一切正常。

CentOS7(Linux domain.com 3.10.0-123.9.3.el7.x86_64 #1 SMP Thu Nov 6 15:06:03 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux)

nginx版本:nginx/1.6.2

OpenSSL 1.0.1e-fips 2013 年 2 月 11 日

这是我的 nginx 配置文件:

server {
  listen 80;
  listen 443 ssl;

  server_name domain.com www.domain.com;

  #SSL config
  ssl on;
  ssl_certificate /etc/nginx/ssl/domain.crt;
  ssl_certificate_key /etc/nginx/ssl/domain.key;
  ssl_session_cache shared:SSL:10m;
  ssl_session_timeout 10m;
  ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
  ssl_ciphers "EECDH+ECDSA+AESGCM EECDH+aRSA+AESGCM EECDH+ECDSA+SHA384 EECDH+ECDSA+SHA256 EECDH+aRSA+SHA384 EECDH+aRSA+SHA256 EECDH EDH+aRSA !RC4 !aNULL !eNULL !LOW !3DES !MD5 !EXP !PSK !SRP !DSS";
  ssl_prefer_server_ciphers on;
  ssl_stapling on;
  resolver 8.8.8.8;
  ssl_stapling_verify on;

  root /home/main/www;
  access_log /var/log/nginx/domain.com-access.log main buffer=16k;
  error_log  /var/log/nginx/domain.com-dev-error.log warn;

  location = /favicon.ico {
        log_not_found off;
        access_log off;
  }

  location = /robots.txt  { access_log off; log_not_found off; }
  location ~ /\.          { access_log off; log_not_found off; deny all; }
  location ~ ~$           { access_log off; log_not_found off; deny all; }

  location ~* .(js|css|png|jpg|jpeg|gif|ico|xml|swf|flv|eot|ttf|woff|pdf|xls|htc|html|unity3d)$ {
  add_header Pragma "public";
  add_header Cache-Control "public, must-revalidate, proxy-revalidate";
     access_log off;
        log_not_found off;
      expires   360d;
  }

  location ~ /.ht {
        deny all;
        access_log off;
         log_not_found off;
 }

  location ~* \.php$ {
        #rewrite ^/(.*)/$ /$1 permanent;
        fastcgi_split_path_info ^(.+.php)(.*)$;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param SCRIPT_NAME $fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_path_info;
        fastcgi_index  index.php;
        fastcgi_pass   unix:/var/run/php5-fpm.sock;
        include        /etc/nginx/fastcgi_params;
  }

  location / {
    index index.php;
    try_files $uri /index.php?$args;
  }
}

远程登录结果:

[user@localhost ~]$ telnet domain.com 80
Trying 123.45.67.89...
Connected to domain.com.
Escape character is '^]'.
^]
HTTP/1.1 400 Bad Request
Server: nginx/1.6.2
Date: Thu, 18 Dec 2014 13:13:20 GMT
Content-Type: text/html
Content-Length: 172
Connection: close

<html>
<head><title>400 Bad Request</title></head>
<body bgcolor="white">
<center><h1>400 Bad Request</h1></center>
<hr><center>nginx/1.6.2</center>
</body>
</html>
Connection closed by foreign host.
[user@localhost ~]$ telnet domain.com 443
Trying 123.45.67.89...
Connected to domain.com.
Escape character is '^]'.
Connection closed by foreign host.

问题解决了。我在全局配置文件行中找到:

server { listen 443 ssl; server_name _; access_log off; error_log off; return 444; }

删除后,一切正常。

4

3 回答 3

1

问题解决了。我在全局配置文件行中找到:

server { listen 443 ssl; server_name _; access_log off; error_log off; return 444; }

删除后,一切正常。

– 古利·鲍里斯

于 2017-02-22T12:03:06.200 回答
0

在此设置中听 433 ssl 是正确的。它允许常规和 ssl 定义位于同一块中,但告诉 nginx 仅在端口 443 请求上启用 ssl。

问题可能出在您的证书文件上。在 nginx 1.6上的同一问题SSL 配置上检查此问题

于 2014-12-19T07:05:04.373 回答
-1

“Listen 443 ssl”看起来是多余的。您应该输入“Listen 443”(稍后在配置中保持“ssl on”)

于 2014-12-18T12:48:33.163 回答