使用此代码,www.bodeind.is重定向到https,但bodeinds.is警告:潜在的安全隐患

时间:2019-04-12 11:40:21

标签: nginx

我同时为www.bodeind.is和bodeind.is安装了Let's Encrypt SSL,但是当我在Firefox中输入bodeind.is时,我得到了警告:潜在的安全隐患。在下面的代码中,关于如何更正此问题的任何建议?当我输入www.bodeind.is时,一切正常。当我在ssllabs.com上进行测试时,www.bodeind.is和bodeind.is都获得了A级评级。

I am running nginx on Ubuntu LTS 18.04
    #
    # Serve bodeind.is and www.bodeind.is
    #
    server {
            root /var/www/bodeind.is/html;
            index index.php index.html index.htm index.nginx-debian.html;
            server_name bodeind.is www.bodeind.is;
    # First attempt to serve request as file, then as directory, then fall back to displaying a 404.
            location / { 
                try_files $uri $uri/ /index.php?$args;
            }
            location ~ \.php$ {
                include snippets/fastcgi-php.conf;
                fastcgi_pass unix:/run/php/php7.0-fpm.sock;
            }
            location ~ /\.ht {
                deny all;
            }
            location = /favicon.ico {
                log_not_found off;
                access_log off;
            }
            location = /robots.txt {
                log_not_found off;
                access_log off;
                allow all;
            }
            location ~* \.(css|gif|ico|jpeg|jpg|js|png)$ {
                expires max;
                log_not_found off;
            }
        listen [::]:443 ssl ipv6only=on; # managed by Certbot
        listen 443 ssl; # managed by Certbot
        ssl_certificate /etc/letsencrypt/live/bodeind.is/fullchain.pem; # managed by Certbot
        ssl_certificate_key /etc/letsencrypt/live/bodeind.is/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.bodeind.is) {
            return 301 https://$host$request_uri;
        } # managed by Certbot
        if ($host = bodeind.is) {
            return 301 https://$host$request_uri;
        } # managed by Certbot
            listen 80 default_server;
            listen [::]:80 default_server;
            server_name bodeind.is www.bodeind.is;
        return 404; # managed by Certbot
    }

1 个答案:

答案 0 :(得分:0)

检查您的TLS证书适用于哪个域。您需要:

  • www.bodeind.is*.bodeind.is,以及
  • bodeind.is

请注意,*.bodeind.is的证书与主机bodeind.is的证书不匹配。

此外,请确保您拥有一个证书。如果您要申请两个不同的证书,但要从同一Web服务器提供域,则一个证书可能会覆盖另一个证书。