【问题标题】:Nginx not matching server_name on httpsNginx 与 https 上的 server_name 不匹配
【发布时间】:2017-06-05 08:32:37
【问题描述】:

我的 nginx 配置与我的 https 服务器不匹配,而是重定向到服务器 ip。

server {
    listen 80 default_server;
    listen [::]:80 default_server;

    server_name www.example.de example.de;

    return 301 https://$server_name$request_uri;
}

server {
    listen 443 ssl default_server;
    listen [::]:443 ssl default_server;

    include snippets/example.conf;
    include snippets/ssl-params.conf;

    server_name www.example.de example.de;

    root /var/www/html;
    index index.php index.html;

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

    location ~ /.well-known {
            allow all;
    }

    error_page 404 /404.html;

    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
            root /usr/share/nginx/html;
    }

    location ~ .php$ {
            try_files $uri =404;
            fastcgi_split_path_info ^(.+.php)(/.+)$;
            fastcgi_pass unix:/var/run/php/php7.0-fpm-butterbirne.sock;
            fastcgi_index index.php;
            include fastcgi.conf;
    }

    client_max_body_size 50m;
}

我已将 default_server 添加到其中,因为一些答案表明 default_server 是匹配所必需的。 Http 在某种程度上很好,但随后它会重定向到机器 ip。我会写127.0.0.1而不是真实ip

root@v22017043237047379:/etc/nginx# curl -I -L http://example.de
HTTP/1.1 301 Moved Permanently
Server: nginx/1.10.3
Date: Mon, 05 Jun 2017 08:30:09 GMT
Content-Type: text/html
Content-Length: 185
Connection: keep-alive
Location: https://www.example.de/

HTTP/1.1 301 Moved Permanently
Server: nginx/1.10.3
Date: Mon, 05 Jun 2017 08:30:10 GMT
Content-Type: text/html; charset=UTF-8
Connection: keep-alive
X-Pingback: https://127.0.0.1/xmlrpc.php
Location: https://127.0.0.1/
Strict-Transport-Security: max-age=63072000; includeSubdomains
X-Frame-Options: DENY
X-Content-Type-Options: nosniff

curl: (51) SSL: certificate subject name 'example.de' does not match target host name '127.0.0.1'

nginx 是 1.10.3 和 os Debian Jessi

【问题讨论】:

    标签: nginx


    【解决方案1】:

    错误是不同的。错误来自wordpress。它被配置为侦听 ip 而不是导致错误重定向的域。

    【讨论】:

      猜你喜欢
      • 2016-07-11
      • 2021-02-20
      • 2018-09-19
      • 1970-01-01
      • 1970-01-01
      • 2016-10-21
      • 1970-01-01
      • 2017-05-05
      • 2016-06-26
      相关资源
      最近更新 更多