我可以请知道如何转发所有请求从端口80到443? 我的代码:转发所有请求从一个端口到另一个nginix
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。 –