proxy.conf 1.05 KB
Newer Older
jose's avatar
jose committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
#反向代理相关配置
#<HOST> 发送域名($host|www.bt.cn)
#<URL> 被代理的URL地址(https://www.bt.cn|https://www.bt.cn/)
#<SUB_OPEN> 是否需要替换字符串(off|on)
#<SRC> 被替换的字符串
#<DST> 替换为

proxy_pass <URL>;
proxy_set_header Host <HOST>;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header Accept-Encoding "";
add_header X-Cache $upstream_cache_status;

proxy_connect_timeout 30s;
proxy_read_timeout 86400s;
proxy_send_timeout 30s;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";


location ~ /purge(/.*) { 
    proxy_cache_purge cache_one <HOST>$request_uri$is_args$args;
}

location / 
{	
    sub_filter "<SRC>" "<DST>";
    sub_filter_once <SUB_OPEN>;
    expires 12h;
}

location ~ .*\.(html|htm|png|gif|jpeg|jpg|bmp|js|css)?$
{   
    proxy_cache cache_one;
    proxy_cache_key $host$request_uri$is_args$args;
    proxy_cache_valid 200 304 301 302 1h;
    expires 24h;
}