nginx cache example vhosts file for website via cpanel

by rajesh 2012-04-15 01:17:09

Here is an example vhosts file used for nginx cache. The virtual host might be added via cpanel too.

This is to be used in the file for the virtual host under /etc/nginx/vhosts/hostname

server {
error_log /var/log/nginx/vhost-error_log warn;
listen 192.168.0.52:80;
server_name hiox.org www.hiox.org;
access_log /usr/local/apache/domlogs/hiox.org-bytes_log bytes_log;
access_log /usr/local/apache/domlogs/hiox.org combined;
location / {
proxy_pass http://192.168.0.52:8081;
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_ignore_headers Cache-Control Expires;
proxy_cache friend;
proxy_cache_valid 200 10m;
}
location ^~ (jpeg|gif|png|ico|flv|jpg)$ {
proxy_pass http://192.168.0.52:8081;
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_cache friend;
proxy_cache_valid 200 8h;
}

location /nginx_status {
stub_status on;
access_log off;
}

}




proxy_cache_path /home/nginxcache levels=1:2
keys_zone=friend:10m
max_size=1g inactive=30m;

has to added in nginx.conf
1340
like
0
dislike
0
mail
flag

You must LOGIN to add comments