"PROXY_STORE" is just a method to store proxied files on disk. It may be used to construct cache-like setups (usually involving try_files and/or error_page-based fallback), though it's up to you to implement any required logic. Lets see the configuration of proxy_store on windows 7.
Enable GZip:
gzip on;
gzip_http_version 1.1;
gzip_vary on;
gzip_comp_level 6;
gzip_proxied any;
gzip_buffers 16 8k;
gzip_disable “MSIE [1-6].(?!.*SV1)”;
Configure port:
listen 88;
server_name localhost;
access_log logs/host.access.log main;
Prevent caching following url:
location ~* \/DiscountShop\/$ {
proxy_pass http://192.168.2.201:80;
}
Proxy pass setup:
if (!-f D:/docroot/ngnix/${request_uri}${store_extra}.html) {
proxy_pass http://192.168.2.201:80;
}
Static files path:
location ~* (css|js|png|jpe?g|gif|ico|swf)$ {
root D:/docroot/;
expires max;
}
Complete configuration files:
nginx.conf
#user nobody;
worker_processes 5; ## Default: 1
error_log logs/error.log;
pid logs/nginx.pid;
worker_rlimit_nofile 8192;
events {
worker_connections 1024;
}
http {
include mime.types;
include fastcgi.conf;
index cache.html cache.htm cache.php;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log logs/access.log main;
sendfile on;
tcp_nopush on;
# Enable gzip for nginx
gzip on;
gzip_http_version 1.1;
gzip_vary on;
gzip_comp_level 6;
gzip_proxied any;
gzip_buffers 16 8k;
# Disable gzip for certain browsers.
gzip_disable “MSIE [1-6].(?!.*SV1)”;
server {
listen 88;
server_name localhost;
access_log logs/host.access.log main;
# Use this to prevent caching pareticular url, send all requests through the proxy.
#location ~ ^/smartphone/en/DiscountShop(New)/ {
#location ~* \/DiscountShop\(New\)\/$ {
# proxy_pass http://localhost:80;
#}
# Main location
location / {
root D:/docroot/ngnix/;
include proxy.conf;
index cache.html cache.htm;
# if the request uri was a directory, store the index page name
if ($request_uri ~ /$) {
set $store_extra cache.html;
}
# set the location the proxy will store the data to. Add the index page
# name if the uri was a directory (nginx can't normally store these)
proxy_store D:/docroot/ngnix/${request_uri}${store_extra};
# go through the proxy if there is no cache
if (!-f D:/docroot/ngnix/${request_uri}${store_extra}) {
proxy_pass http://localhost:80;
}
# workaround. headers module doesn't take into account proxy response
# headers. It overwrites the proxy Cache-Control header, causing
# private/no-cache/no-store to be wiped, so only set if not using proxy
#if (-f D:/docroot/ngnix/${request_uri}${store_extra}) {
# expires 0;
#}
# Static files are cashed for 1 day.
# Set their expiry time to max, so they'll always use the browser cache after first request.
# location ~* (swf|jp?g|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js|TTF)$ {
# root D:/docroot/ngnix/;
# if (!-f D:/docroot/ngnix/${request_uri}) {
# proxy_pass http://localhost:80;
# }
# proxy_cache_valid 1d;
# expires max;
# }
# Do not cache static files. Read them from local docroot.
# Set their expiry time to max, so they'll always use the browser cache after first request.
location ~* (swf|jp?g|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js|TTF)$ {
root D:/docroot/;
expires max;
}
}
}
}
proxy.conf
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;
client_max_body_size 10m;
client_body_buffer_size 128k;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_buffers 32 4k;
No comments:
Post a Comment