什么重定向URL http://www.mysite.com/login到HTTPS:在nginx的代理级别//www.mysite.com/login,这将避免任何的Django机械被加载,使其更快速和响应。
你可以添加到您的nginx配置
location /login {
# redirect to secure page [permanent | redirect]
rewrite ^/login(.*) https://www.mysite.com/login permanent;
}
basicly重定向任何/登录到它的HTTPS conterpart。
希望它有帮助。
UPDATE
确保你听端口443
server {
listen yourIP:80;
server_name yourdomain.com;
# redirect /login to the https page
location /login {
# redirect to secure page [permanent | redirect]
rewrite ^/login(.*) https://www.mysite.com/login permanent;
}
}
#the HTTPS section listening to port 443
server {
listen yourIP:443;
server_name yourdomain.com;
location/{
#your proxy code or root setting
}
}
由于某种原因,这是行不通的。之前,我插入此配置并重新启动nginx的,要去“https://开头正常工作后,我插入这个配置和启动服务器,从http重定向://为” https://开头的作品,但我得到一个网页“无法连接”的错误。任何线索,怎么回事? – josephmisiti 2011-01-13 05:19:21