即使没有此类文件,nginx重定向

时间:2019-02-14 21:55:08

标签: nginx digital-ocean certbot

我在数字海洋上将nginx和cerbot一起使用。我是nginx的新手。我在启用站点的站点中只有一个文件。该文件包含以下内容:现在,当我向albahriacssacademy.com发送请求时,我将重定向到以前使用的另一个域。

我知道这可能不会链接,但是我已经删除了所有证书并也更新了它们。也请参见下面的卷曲响应。这里发生了什么以及如何避免这种情况。

server {
    root /var/www/html/;

    index index.php index.html index.htm index.nginx-debian.html;

    server_name albahriacssacademy.com www.albahriacssacademy.com;

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

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

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/run/php/php7.0-fpm.sock;
    }


    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/albahriacssacademy.com/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/albahriacssacademy.com/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot


}



server {
    if ($host = www.albahriacssacademy.com) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


    if ($host = albahriacssacademy.com) {
        return 301 https://$host$request_uri;
    } # managed by Certbot



    server_name albahriacssacademy.com www.albahriacssacademy.com;
    listen 80;
    return 404; # managed by Certbot
}

但是我得到以下回应

curl -L albahriacssacademy.com -v
* Rebuilt URL to: albahriacssacademy.com/
*   Trying 206.189.36.41...
* Connected to albahriacssacademy.com (206.189.36.41) port 80 (#0)
> GET / HTTP/1.1
> Host: albahriacssacademy.com
> User-Agent: curl/7.47.0
> Accept: */*
> 
< HTTP/1.1 301 Moved Permanently
< Server: nginx/1.10.3 (Ubuntu)
< Date: Thu, 14 Feb 2019 21:41:14 GMT
< Content-Type: text/html
< Content-Length: 194
< Connection: keep-alive
< Location: https://albahriacssacademy.com/
< 
* Ignoring the response-body
* Connection #0 to host albahriacssacademy.com left intact
* Issue another request to this URL: 'https://albahriacssacademy.com/'
* Found bundle for host albahriacssacademy.com: 0x5556830c0330 [can pipeline]
*   Trying 206.189.36.41...
* Connected to albahriacssacademy.com (206.189.36.41) port 443 (#1)
* found 148 certificates in /etc/ssl/certs/ca-certificates.crt
* found 594 certificates in /etc/ssl/certs
* ALPN, offering http/1.1
* SSL connection using TLS1.2 / ECDHE_RSA_AES_128_GCM_SHA256
*    server certificate verification OK
*    server certificate status verification SKIPPED
*    common name: albahriacssacademy.com (matched)
*    server certificate expiration date OK
*    server certificate activation date OK
*    certificate public key: RSA
*    certificate version: #3
*    subject: CN=albahriacssacademy.com
*    start date: Thu, 14 Feb 2019 20:40:22 GMT
*    expire date: Wed, 15 May 2019 20:40:22 GMT
*    issuer: C=US,O=Let's Encrypt,CN=Let's Encrypt Authority X3
*    compression: NULL
* ALPN, server accepted to use http/1.1
> GET / HTTP/1.1
> Host: albahriacssacademy.com
> User-Agent: curl/7.47.0
> Accept: */*
> 
< HTTP/1.1 301 Moved Permanently
< Server: nginx/1.10.3 (Ubuntu)
< Date: Thu, 14 Feb 2019 21:41:14 GMT
< Content-Type: text/html; charset=UTF-8
< Transfer-Encoding: chunked
< Connection: keep-alive
< Location: https://albahriainstitute.com/
< 
* Ignoring the response-body
* Connection #1 to host albahriacssacademy.com left intact
* Issue another request to this URL: 'https://albahriainstitute.com/'
*   Trying 206.189.36.41...
* Connected to albahriainstitute.com (206.189.36.41) port 443 (#2)
* found 148 certificates in /etc/ssl/certs/ca-certificates.crt
* found 594 certificates in /etc/ssl/certs
* ALPN, offering http/1.1
* SSL connection using TLS1.2 / ECDHE_RSA_AES_128_GCM_SHA256
*    server certificate verification OK
*    server certificate status verification SKIPPED
* SSL: certificate subject name (albahriacssacademy.com) does not match target host name 'albahriainstitute.com'
* Closing connection 2
curl: (51) SSL: certificate subject name (albahriacssacademy.com) does not match target host name 'albahriainstitute.com'

0 个答案:

没有答案