标签:重定向 访问 usr logs cer 链接 key www targe
参考:博文
参考:HTTP 状态码解读
Nginx Server 配置
server { listen 80; server_name www.test.com test.com; rewrite ^(.*)$ https://$host$1 permanent; } server { listen 443 ssl; server_name www.ourdax.com; ssl_certificate /usr/local/openresty/nginx/conf/ssl/test.pem; ssl_certificate_key /usr/local/openresty/nginx/conf/ssl/test.key; root /usr/local/openresty/nginx/html; index index.html; location / { } }
关于 Nginx 状态码 497
497 - normal request was sent to HTTPS
当此虚拟站点只允许https访问时,当用http访问时nginx会报出497错误码
实现跳转思路
利用 error_page 命令将 497 状态码的链接重定向到指定 URL
Nginx Server 配置
server { listen 443 ssl; listen 80; server_name www.test.com; ssl_certificate /usr/local/openresty/nginx/conf/ssl/test.pem; ssl_certificate_key /usr/local/openresty/nginx/conf/ssl/test.key; root /usr/local/openresty/nginx/html; index index.html; location / { } error_page 497 https://$host$uri?$args; }
关于 原博文 在 html 里用 refresh 的方式做跳转的方式我不是很认可,还是把这些事情交给 web server 处理好一些。
标签:重定向 访问 usr logs cer 链接 key www targe
原文地址:http://www.cnblogs.com/tiantiandas/p/nginx_http_to_https.html