0

我有一个域名,example.com现在我有服务器在 VPS 中运行并且example.com工作正常。现在我想重定向www.example.comhttps://example.com

工作: 当用户登陆时http://example.com-> nginx->https://example.com现在我想要

我想要:http://www.example.com ->https://example.comhttp://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;
}
4

0 回答 0