【发布时间】:2017-01-22 20:56:30
【问题描述】:
请问如何将所有来自端口 80 的请求转发到 443? 我的代码:
server {
listen 80;
root /var/www/html/;
index index.html index.htm index.php;
server_name myexample.com;
location / {
proxy_pass http://myexample.com:443/;
}
}
server {
listen 443;
root /var/www/html/;
index index.html index.html index.php;
server_name myexample.com;
}
但对http://myexample.com 的请求不会重定向到https://myexample.com
【问题讨论】:
-
为什么要proxy_pass,什么时候可以/应该重定向到HTTPS?
-
我认为 proxy_pass 会做转发。
-
是的。它会。但是浏览器和网站之间的连接仍然是 HTTP(未加密)。如果您打算加密连接,则应将 HTTP 重定向到 HTTPS,而不是 proxy_pass。
-
我想学习如何将 http 重定向到 https .. 你能解释一下吗?
-
请看答案
标签: apache nginx webserver sysadmin nginx-location