Hi, I need some help here below is my config on my nginx server. I serve static files js, css, jpeg files. I seems my reverse proxy is not working everything I update my css or other file on my static server I need to clear cache to be able to reflect my new css and images file. How can I prevent to clear cache every now and then and new css, images will be loaded on my cache also once file is being cache no need to load again from the client side. Please let me know what was wrong on below config.
Nginx.conf
Code:#Run as webuser to minimize permission conflict user nginx nginx; # For high performance you'll need one worker process per disk spindle # but in most cases 1 or 2 is fine. worker_processes 1; error_log /var/log/nginx/error.log debug; pid /var/run/nginx.pid; events { # Max concurrent connections = worker_processes * worker_connections # You can increase this past 1024 but you must set the rlimit before starting # ngxinx using the ulimit command (say ulimit -n 8192) worker_connections 1024; #Linux performance awesomeness on use epoll; } http { #server_name_hash_bucket_size 64; #Mime stuff #Mime-type table include /etc/nginx/mime.types; default_type application/octet-stream; #Size Limits client_max_body_size 200M; client_body_buffer_size 8M; client_header_buffer_size 128k; large_client_header_buffers 1 8k; #Time out client_body_timeout 120; client_header_timeout 120; send_timeout 120; keepalive_timeout 60 60; ignore_invalid_headers on; recursive_error_pages on; # Where to store the body of large client requests on disk # NGINX will stream this to disk before posting it to your Mongrels, # preventing slow clients tying up your app. client_body_temp_path /var/log/nginx/nginx-client-body/tmp 1 2; proxy_cache_path /var/log/nginx/nginx-client-body levels=1:2 keys_zone=main:1024m inactive=7d max_size=1000m; log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; #Compression gzip on; gzip_http_version 1.0; gzip_comp_level 2; gzip_proxied any; gzip_min_length 1100; gzip_buffers 16 8k; #Some version of IE 6 don't handle compression well on some mime-types, so just diable for them gzip_disable "MSIE [1-6].(?!.*SV1)"; #Set a vary header so downstream proxies don't send cached gzipped content to IE6 gzip_vary on; server_tokens off; sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_requests 0; server { listen 192.168.0.15:80 default; server_name _; access_log /var/log/nginx/access.log main; location / { proxy_pass http://127.0.0.1:8080; include /etc/nginx/proxy.conf; } } include /etc/nginx/conf.d/*[^~]; }
Proxy.conf
virtual.confCode: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; proxy_cache main; proxy_cache_key backend$request_uri; proxy_cache_valid 200 301 302 20m; # Cache pages for 20mins proxy_cache_valid 200 304 7d; # Cache pages for 7day proxy_cache_valid 301 302 1h; # Cache pages for 1 hour proxy_cache_valid 404 403 402 401 504 502 20m; # Cache Other errors for 20mins proxy_cache_valid any 15m; # Cache others for 15 minute proxy_cache_valid 404 1m; # Cache errors for 1 minute proxy_cache_use_stale error timeout invalid_header updating; proxy_connect_timeout 180; proxy_send_timeout 180; proxy_read_timeout 180; proxy_buffers 8 16k; proxy_buffer_size 32k; proxy_busy_buffers_size 64k; proxy_temp_file_write_size 64k; proxy_pass_header Expires; proxy_pass_header Cache-Control; proxy_pass_header Last-Modified; proxy_pass_header ETag; proxy_pass_header Content-Length;
Code:server { listen 192.168.0.15:80; server_name _; server_name_in_redirect off; resolver 127.0.0.1; root /var/www/html/public_html; access_log /var/log/nginx/access.log main; if (-f $request_filename) { break; } location / { proxy_pass http://127.0.0.1:8080; include /etc/nginx/proxy.conf; } location ^~ (jpeg|gif|png|ico|flv|hqx|cpt|csv|text|bin|dms|lha|lzh|exe|clas|psd|so|sea|dll|oda|pdf|ai|eps|ps|smi|smil|mif|xls|ppt|wbxml|wmlc|dcr|dir|dxr|dvi|gtar|gz|php|php4|php3|phps|js|swf|sit|tar|tgz|xhmtl|xht|zip|mid|midi|mpga|mp2|mp3|aif|aifc|ram|rm|rpm|ra|rv|wav|bmp|jpe|tiff|tif|css|html|htm|shtml|txt|log|rtx|rtf|xml|xsl|mpeg|mpg|mpe|qt|mov|avi|movie|doc|docx|xlsx|xl|eml|ttf)$ { expires 30d; proxy_cache main; } }


