我的 SSL 证书用于 mydomain.com,所以我试图将所有 www.mydomain.com 重定向到不带 www 的。现在,所有这些工作:
http://www.mydomain.com
http://mydomain.com
https://mydomain.com
Run Code Online (Sandbox Code Playgroud)
但是https://www.mydomain.com向浏览器发出“站点不安全”警告......我尝试设置如下重定向,但请告诉我我的脚本在哪里有问题......
server {
listen 80;
server_name www.mydomain.com mydomain.com;
rewrite ^(.*) https://mydomain.com$1 permanent;
client_max_body_size 100M;
location / {
index index.htm index.html index.php;
}
location ~ \.php$ {
include fastcgi_params;
fastcgi_index index.php;
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME /var/www/mysite$fastcgi_script_name;
}
}
server {
listen 443;
ssl on;
ssl_certificate /usr/local/nginx/conf/public.crt;
ssl_certificate_key /usr/local/nginx/conf/server.key;
server_name www.mydomain.com;
rewrite ^(.*) https://mydomain.com$1 permanent;
}
server {
listen 443;
ssl on;
ssl_certificate /usr/local/nginx/conf/public.crt;
ssl_certificate_key /usr/local/nginx/conf/server.key;
client_max_body_size 100M;
server_name …Run Code Online (Sandbox Code Playgroud) 我在使用 nginx 配置从 HTTPS www 重定向到 HTTPS non-www 时遇到了一些问题。我正在按照(删除“www”并使用 nginx 重定向到“https”)提供的说明进行操作。
现在有以下工作:
但这不会:
我最终得到了“欢迎使用 nginx!” 页。我没有任何其他 nginx 配置文件/sites-enabled。任何想法为什么会这样做?
我的配置文件在下面。
upstream redemfit {
server unix:/srv/redemfit/run/gunicorn.sock fail_timeout=0;
}
server {
listen 80;
server_name www.redemfit.com redemfit.com;
rewrite ^ https://redemfit.com$request_uri? permanent;
}
server {
listen 443;
ssl on;
ssl_certificate /etc/ssl/private/redemfit-bundle.crt;
ssl_certificate_key /etc/ssl/private/redemfit.key;
ssl_protocols SSLv3 TLSv1;
ssl_ciphers ALL:!aNULL:!ADH:!eNULL:!LOW:!EXP:RC4+RSA:+HIGH:+MEDIUM;
server_name www.redemfit.com
rewrite ^ https://redemfit.com$request_uri? permanent;
}
server {
listen 443;
ssl on; …Run Code Online (Sandbox Code Playgroud)