我有一个域名,example.com
现在我有服务器在 VPS 中运行并且example.com
工作正常。现在我想重定向www.example.com
到https://example.com
工作:
当用户登陆时http://example.com
-> nginx
->https://example.com
现在我想要
我想要:http://www.example.com
->https://example.com
或http://example.com
这是我现有的域配置
nginx 配置
upstream backend {
server localhost:3000;
server localhost:3001;
}
server {
listen 443 ssl;
server_name example.com;
ssl_certificate cert.cert;
ssl_certificate_key privatekey.key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers HIGH:!aNULL:!MD5;
location / {
proxy_pass http://backend;
}
}
server {
listen 80;
server_name www.example.com;
return 301 https://example.com$request_uri;
}
server {
listen 443;
server_name www.example.com;
return 301 https://example.com$request_uri;
}
server {
listen 80;
return 301 https://$host$request_uri;
}