nginx1.4.7 Use ngx_http_proxy_module to realize the static resource cache
gaoping at richinfo.cn
gaoping at richinfo.cn
Thu May 22 08:41:40 UTC 2014
hi
I use ngx_http_proxy_module to realize the static resource cache,Unable to generate a cache file,Below is the nginx.conf configuration information,Trouble you to help have a look what is the reason。
worker_processes 4;
events {
use epoll;
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
proxy_temp_path /home/se/nginx_cache/tmp_nc1 1 2;
proxy_cache_path /home/se/nginx_cache/nc1 levels=1:2 keys_zone=nc1:50m;
upstream bj{
server 192.168.1.107:7111;
}
upstream noBj{
server 192.168.1.106:7111;
}
server {
listen 50001;
server_name localhost;
access_log logs/host.access.log main;
location / {
proxy_set_header Host $host:20001;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_next_upstream http_502 http_504 error timeout invalid_header;
if ( $geoip_city != 'Beijing' ){
proxy_pass http://noBj;
}
if ( $geoip_city = 'Beijing' ){
proxy_pass http://bj;
}
}
location ~*\.(jpg|gif|png|css|swf|js)$ {
if ( $geoip_city != 'Beijing' ){
proxy_pass http://noBj;
}
if ( $geoip_city = 'Beijing' ){
proxy_pass http://bj;
}
proxy_cache nc1;
proxy_cache_valid 200 302 304 1d;
proxy_cache_key $host$uri$is_args$args;
proxy_cache_lock on;
proxy_cache_lock_timeout 2s;
expires 1d;
}
}
gaoping at richinfo.cn
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20140522/19f0a944/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cache.png
Type: image/png
Size: 49273 bytes
Desc: not available
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20140522/19f0a944/attachment-0001.png>
More information about the nginx
mailing list