Wordpress + Nginx + php-fpm の環境でNginxのリバースプロキシ+ブラウザーキャッシュを使用しています。
60万req/時を捌きたいのですが外部リンクからのjavascript、画像だったりをキャッシュしたいのですが
こういうのは可能なのでしょうか。
JMeterでテストを行うと自サーバーのコンテンツはエラーが無く順調なのですが、外部から引っ張ってきてるものがエラーを出してしまっている状況です。
参考になるか分かりませんが下記がNginxのコンフィグになります。
何かご教授いただければよろしくお願いします。
nginx.conf user nginx; worker_processes auto; worker_rlimit_nofile 150000; events { worker_connections 65535; use epoll; multi_accept on; } http { include mime.types; 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"'; sendfile on; tcp_nopush on; server_names_hash_bucket_size 64; keepalive_timeout 0; gzip on; gzip_disable "MSIE [1-6]\."; gzip_proxied any; gzip_min_length 1024; gzip_comp_level 6; gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript; proxy_max_temp_file_size 2048M; proxy_buffers 100 8k; proxy_buffer_size 8k; proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=czone:15m max_size=60g inactive=7d; proxy_temp_path /var/tmp/nginx; proxy_cache_key $scheme://$host$request_uri; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-Proto https; proxy_set_header X-Forwarded-Host $host; proxy_set_header X-Forwarded-Server $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; set_real_ip_from 127.0.0.1; real_ip_header X-Forwarded-For; upstream xxx { ip_hash; server 127.0.0.1:8081; } include /etc/nginx/conf.d/*; }
conf.d/default.conf server { listen 80; server_name 111; charset utf-8; access_log /var/log/nginx/access_log main; error_log /var/log/nginx/error_log; root /var/www/chroot-website; client_max_body_size 1G; add_header X-Cache $upstream_cache_status; location /nginx_status { stub_status on; access_log off; } location = /favicon.ico { access_log off; log_not_found off; } location = /robots.txt { access_log off; log_not_found off; } location ~ \.ico$ { log_not_found off; access_log off; expires max; } location ~ \.(css|js)$ { proxy_pass http://xxx; charset UTF-8; access_log off; } location ~* \.(jpe?g|gif|png|ico|woff|svg|swf|inc)$ { proxy_pass http://xxx; access_log off; } location /wp-content/uploads { proxy_pass http://xxx; access_log off; } location ~ /\. { deny all; access_log off; log_not_found off; } location = /wp-config.php { deny all; access_log off; } location ~ .*\.php { proxy_pass http://xxx; } location / { set $do_not_cache 0; if ($http_cookie ~* "comment_author_|wordpress_(?!test_cookie)|wp-postpass_|wordpress_logged_in" ) { set $do_not_cache 1; } if ($request_method != GET) { set $do_not_cache 1; } # mobile setting include /etc/nginx/mobile_cache_setting; proxy_cache_valid 200 302 180m; proxy_cache_valid 404 7d; proxy_no_cache $do_not_cache; proxy_cache_bypass $do_not_cache; proxy_cache czone; proxy_cache_key $scheme://$host$uri$is_args$args; proxy_pass http://xxx; } } server { listen 8081; server_name 111; root /var/www/chroot-website; index index.php; access_log /var/log/nginx/access8081.log; error_log /var/log/nginx/error8081.log; location / { try_files $uri $uri/ /index.php?q=$uri&$args; location ~ /wp-content { access_log off; include /etc/nginx/php_exec; } location ~ /wp-includes { access_log off; include /etc/nginx/php_exec; } location ~ /wp-cron.php { access_log off; include /etc/nginx/php_exec; } location ~ /wp-comments { access_log off; include /etc/nginx/php_exec; } location ~ /wp-admin { access_log off; include /etc/nginx/php_exec; } location ~ /wp-login.php { access_log off; include /etc/nginx/php_exec; } include /etc/nginx/php_exec; } }
nginx/php_exec location ~\.php$ { expires off; fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; }