最简单的Nginx反代+ssl配置

作者:admin | 时间:August 29, 2012 | 分类:host | 评论:0 ℃
server {
server_name www.aaa.com;
listen 80;
rewrite ^/(.*)$ https://$host/$1 redirect;
}
server {
server_name www.aaa.com;
listen 443;
ssl on;
ssl_certificate /home/wwwroot/server.crt;
ssl_certificate_key /home/wwwroot/server.key;
location / {
proxy_pass http://www.bbb.com/;
proxy_redirect off;
#proxy_set_header Host $host;(有些网站没有它不让登陆,有些网站因为有它而不能替代域名,一般不需要。)
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
用www.aaa.com反代www.bbb.com,ssl部分根据自己的情况设定。