0

centos vpsでApacheを使用してフロントエンドプロキシとしてNginxをセットアップしました。最近、特定の Web サイトの構成ファイルまたは nginx.conf ファイル自体を変更しようとしても、変更が見られません。nginx と apache を再起動し、nginx temp ディレクトリをクリアしました。

たとえば、gzip_http_version を 1.1 から 1.0 に変更したときに最初に気付きました。ヘッダーを確認しましたが、変更はありませんでした。conf ファイルにランダムな文字を追加することもできますが、すべて問題なく動作します。

サイト conf ファイルの例を次に示します。

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;
          }
}

ここに私のnginx.confファイルがあります

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/*";
}

追加する必要があるその他の追加情報がある場合は、お知らせください。

4

1 に答える 1

1

サーバー側でnginxを再起動すると、新しい構成が有効になるはずです(変更された構成が有効であると想定しています。nginx -t確認してみてください。壊れた構成でnginxをリロードすると、古い構成で実行され続けます)

したがって、追加しているキャッシュヘッダーが問題の原因であると思います。

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

あなたは基本的に、あなたの下流のすべてに、今後30日間は何も変わらないことを伝えています...

その結果、クライアントは (変更された) ページを再リクエストする代わりに、ブラウザーのキャッシュ (または間にあるプロキシのキャッシュ) を使用しています。

wgetまたはで変更されたページをリクエストすることでcurl、プロキシやブラウザキャッシュの干渉を排除することで確認できます。

于 2013-03-01T22:13:15.427 に答える