我在同一台服务器上托管了两个域
testwebsite.com
和
staging.testwebsite.com
. 我添加了nginx配置,其中有一个问题子域只能在非安全协议上重定向到主域。
http://testwebsite.com
-gt;
https://testwebsite.com
=好
https://testwebsite.com网站
-gt;
https://testwebsite.com网站
=好
http://staging.testwebsite.com
-gt;
https://testwebsite.com网站
不好
https://staging.testwebsite.com
-gt;
https://staging.testwebsite.com网站
=正常
TestWebSITecom
server {
root /var/www/testwebsite.com/live;
index index.html index.php index.htm index.nginx-debian.html;
server_name testwebsite.com www.testwebsite.com;
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
}
location ~ /\.ht {
deny all;
}
listen [::]:443 ssl;
listen 443 ssl;
ssl_certificate /etc/letsencrypt/live/testwebsite.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/testwebsite.com/privkey.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
}
server {
listen 80;
listen [::]:80;
server_name testwebsite.com www.testwebsite.com;
return 301 https://testwebsite.com$request_uri;
}
staging.testwebiste.com网站
server {
root /var/www/testwebsite.com/staging;
index index.html index.php index.htm index.nginx-debian.html;
server_name staging.testwebsite.com www.staging.testwebsite.com;
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
}
location ~ /\.ht {
deny all;
}
listen [::]:443 ssl;
listen 443 ssl;
ssl_certificate /etc/letsencrypt/live/staging.testwebsite.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/staging.testwebsite.com/privkey.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
}
server {
listen 80;
listen [::]:80;
server_name staging.testwebsite.com www.staging.testwebsite.com;
return 301 https://staging.testwebsite.com$request_uri;
}
有人能帮一下配置出了什么问题吗?