谷歌域名www到裸域

时间:2018-01-20 00:43:04

标签: nginx google-domains

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

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

我想: http://www.example.com - > https://example.comhttp://example.com

这是我现有的域配置

enter image description here

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;
}

0 个答案:

没有答案