搭了个 GHOST 博客,启用了 https 。
现在想让 http 请求跳到 https ,并且 www 请求跳到非 www 上。应该怎么做呢??搜索了几个配置都有问题。。
1
dommyet 2016-03-04 02:08:55 +08:00 via Android 1
return 301 xxx.xxx.xxx
|
2
shiny 2016-03-04 02:10:32 +08:00 1
listen 80;
listen 443 ssl; if ($server_port ~ 80) { return 301 https://example.com$request_uri; } https 跳转 至于 www 的跳转 我是建一个 server_name 为 www.example.com ,然后 return 301 你也可以对 $host 做判断再跳转。 google 搜下,很多 SO 的答案都有用。 |
3
ryd994 2016-03-04 04:05:01 +08:00 via Android 1
|
4
ewBuyVmLZMZE 2016-03-04 04:18:52 +08:00 1
www 这个我直接在 DNS 上配置了解析跳转。
然后 Nginx 配置 HTTP 跳转 HTTPS : server { listen 80; server_name xxx.xxx; location / { rewrite (.*) https://xxx.xxx$1 permanent; } } server { listen 443 ssl http2; server_name xxx.xxx; # let the browsers know that we only accept HTTPS add_header Strict-Transport-Security "max-age=63072000; includeSubdomains; preload"; ssl on; ssl_certificate /path/to/crt; ssl_certificate_key /path/to/key; ssl_dhparam /path/to/pem; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_stapling on; ssl_ciphers "EECDH+AESGCM:EDH+AESGCM:ECDHE-RSA-AES128-GCM-SHA256:AES256+EECDH:DHE-RSA-AES128-GCM-SHA256:AES256+EDH:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA:ECDHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES128-SHA256:DHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES256-GCM-SHA384:AES128-GCM-SHA256:AES256-SHA256:AES128-SHA256:AES256-SHA:AES128-SHA:DES-CBC3-SHA:HIGH:!aNULL:!eNULL:!EXPORT:!DES:!MD5:!PSK:!RC4"; ssl_prefer_server_ciphers on; ssl_session_cache shared:SSL:10m; ssl_session_timeout 10m; location / { proxy_set_header X-Real-IP $remote_addr; proxy_set_header Host $http_host; proxy_pass http://127.0.0.1:xxxx; } } |
5
Roope 2016-03-04 09:15:19 +08:00
|
6
popu111 2016-03-04 12:20:05 +08:00 via Android
spdy 换 http2 ,另外懒得折腾还是上 typecho 或者 wp 这种吧
|