简体   繁体   English

我在 Nginx 中从 http 重定向到 https 不工作

[英]My redirect from http to https in Nginx not working

server {
    listen      80;
    server_name www.21cl.ca 21cl.ca;
    return 301 https://21cl.ca$request_uri;
}

server {
        server_name 21cl.ca;
        listen 443 ssl http2;
        ssl_certificate /srv/ssl/2100computerlane_net.crt;
        ssl_certificate_key /srv/ssl/21ca.key;
        ssl_protocols TLSv1.2;
        ssl_prefer_server_ciphers on;
        ssl_ciphers ECDH+AESGCM:ECDH+AES256:ECDH+AES128:DH+3DES:!ADH:!AECDH:!MD5;
        access_log /srv/www/www.2100computerlane.net/logs/access.log;
        error_log /srv/www/www.2100computerlane.net/logs/error.log;
        root /srv/www/www.2100computerlane.net/public_html;

        location / {
                index index.html index.htm index.php;
                autoindex on;
                autoindex_exact_size off;
        }

        location ~* \.php$ {
                include /etc/nginx/fastcgi_params;
                fastcgi_pass 127.0.0.1:9000;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                fastcgi_param SCRIPT_NAME $fastcgi_script_name;
        }
}

http://www.21cl.ca is being forwarded to https://www.21cl.ca not https://21cl.ca like instructed. http://www.21cl.ca被转发到https://www.21cl.ca而不是https://21cl.ca按照指示转发。

Note this works fine when I do it with my dot.net and dot com domains.请注意,当我使用我的 dot.net 和 dot com 域时,它工作正常。

I think it has been cached in the browser try it in private or incognito window, It is redirecting properly for me我认为它已缓存在浏览器中,请私下或隐身尝试 window,它为我正确重定向

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM