nginx http和https反向代理的配置

发表于

HTTP反向代理

server
{
listen 80;
server_name docs.pony.hk;
location / {
proxy_cache cache_one;
proxy_cache_key $host$uri$is_args$args;
proxy_cache_valid 200 304 302 6h;
expires 6h;
subs_filter 'https://docs.google.com' 'http://docs.pony.hk' gi;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Referer https://docs.google.com;
proxy_set_header Host docs.google.com;
proxy_pass https://docs.google.com;
proxy_set_header Accept-Encoding "";
#proxy_redirect ~^https://docs.google.com(.*) http://docs.pony.hk$1;
}
}

https反向代理

server {
listen 443;
server_name downloads.pony.hk;
ssl on;
ssl_certificate /etc/nginx/keys_for_ssl/server.crt;
ssl_certificate_key /etc/nginx/keys_for_ssl/server.key;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Referer https://downloads.wordpress.org;
proxy_set_header Host downloads.wordpress.org;
proxy_pass https://downloads.wordpress.org;
proxy_set_header Accept-Encoding "";
}
}