0

I have Nginx set up as a front end proxy with apache on a centos vps. Recently, when I go to change the configuration file for a specific website or the nginx.conf file itself, I am not seeing any changes. I have restarted nginx and apache, as well as, clearing out the nginx temp directory.

For example, I first noticed when I changed gzip_http_version from 1.1 to 1.0. I checked my headers but there was no change. I can also add random characters to the conf file and everything will still work ok.

Here is an example of a site conf file.

server {
          error_log /var/log/nginx/vhost-error_log warn;
           listen 204.197.248.70:80;
          server_name www.website.com;
          access_log /usr/local/apache/domlogs/www.website.com-bytes_log bytes_log;
          access_log /usr/local/apache/domlogs/www.website.com combined;
          root /home/www.website.com/public_html;
          location / {
          location ~.*\.(3gp|gif|jpg|jpeg|png|ico|wmv|avi|asf|asx|mpg|mpeg|mp4|pls|mp3|mid|wav|swf|flv|html|htm|txt|js|css|exe|zip|tar|rar|gz|tgz|bz2|uha|7z|doc|docx|xls|xlsx|pdf|iso)$ {
          expires 30d;
    add_header Pragma public;
    add_header Cache-Control "public";
          try_files $uri @backend;
          }
          error_page 405 = @backend;
          add_header X-Cache "HIT from Backend";
          proxy_pass http://1.1.1.1.:8081;
          include proxy.inc;
          }
          location @backend {
          internal;
          proxy_pass http://1.1.1.1:8081;
          include proxy.inc;
          }
          location ~ .*\.(php|jsp|cgi|pl|py)?$ {
          proxy_pass http://1.1.1.1:8081;
          include proxy.inc;
          }
          location ~ /\.ht {
          deny all;
          }
}

Here is my nginx.conf file

user  user;
# no need for more workers in the proxy mode
worker_processes  2;
error_log  /var/log/nginx/error.log info;
worker_rlimit_nofile 20480;
events {
 worker_connections 5120; # increase for busier servers
 use epoll; # you should use epoll here for Linux kernels 2.6.x
}
http {
 server_name_in_redirect off;
 server_names_hash_max_size 10240;
 server_names_hash_bucket_size 1024;
 include    mime.types;
 default_type  application/octet-stream;
 server_tokens off;
# remove/commentout disable_symlinks if_not_owner;if you get Permission denied error
# disable_symlinks if_not_owner;
 sendfile off;
 tcp_nopush on;
 tcp_nodelay on;
 keepalive_timeout  5;

 ignore_invalid_headers on;
 client_header_timeout  3m;
 client_body_timeout 3m;
 send_timeout     3m;
 reset_timedout_connection on;
 connection_pool_size  256;
 client_header_buffer_size 256k;
 large_client_header_buffers 4 256k;
 client_max_body_size 200M; 
 client_body_buffer_size 128k;
 request_pool_size  32k;
 output_buffers   4 32k;
 postpone_output  1460;
 proxy_temp_path  /tmp/nginx_proxy/;
 client_body_in_file_only on;
 log_format bytes_log "$msec $bytes_sent .";
 include "/etc/nginx/vhosts/*";
}

If there is any other additional info I need to add please let me know.

user715564
  • 1,650
  • 2
  • 25
  • 60
  • does the browser support 1.1? if the browser specifies it only supports 1.0, your 1.1 will be ignored. – bizzehdee Mar 01 '13 at 20:06
  • I am using the latest versino of chrome so yeah it does. That's not really the problem though. – user715564 Mar 01 '13 at 20:08
  • not sure if this resolves the same issue you are having, but maybe take a look at some of the answers in http://stackoverflow.com/questions/6236078/how-to-clear-the-cache-of-nginx – bizzehdee Mar 01 '13 at 20:10
  • Yeah I have already looked over that topic. Thanks for the suggestion. – user715564 Mar 01 '13 at 20:19
  • NGINX configurations, as well as Apache configurations (aside from .htaccess) are not parsed at runtime. You must, at the very least, reload the configs to get the changes to take place. Additionally, are you using anything such as cloudflare that might be in front of your setup? – Brendan Mar 01 '13 at 21:38
  • Ok, I see. how I set nginx up is by using the cpanel admin http://nginxcp.com/. From whm I am restarting nginx after each change. Is that the same as reloading the configs? I am not using cloudflare but I noticed the problem when setting cloudfront up with w3 total cache on a wordpress multisite installation. Since then, I have deleted the w3 total cache plugin. – user715564 Mar 01 '13 at 21:54

1 Answers1

1

serverside the restart of nginx should've activated the new config (I'm assuming your changed configuration is valid, try nginx -t to check that, if you reload the nginx with a broken config it'll keep running with the old one)

so my guess is the problem is caused by the cache headers you're adding:

expires 30d;
add_header Pragma public;
add_header Cache-Control "public";

you're basically telling everything downstream of you that nothing will change for the next 30 days...

consequently the clients are using their browser's cache (or the cache of any proxy that's in between), instead of re-requesting the (changed) page

you can check that by requesting a changed page with wget or curl that should eliminate any proxies or browsercaches from interfering.

cobaco
  • 10,224
  • 6
  • 36
  • 33