我有一个名为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 config
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;
}