This shows you the differences between two versions of the page.
| — | linux:nginx [2021/07/27 15:38] (current) – created - external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | [[http:// | ||
| + | |||
| + | [[https:// | ||
| + | |||
| + | [[https:// | ||
| + | |||
| + | [[https:// | ||
| + | |||
| + | ====== nginx ====== | ||
| + | [[http:// | ||
| + | |||
| + | ====== sample config ====== | ||
| + | < | ||
| + | events { | ||
| + | use epoll; | ||
| + | multi_accept on; | ||
| + | } | ||
| + | |||
| + | sendfile | ||
| + | tcp_nopush | ||
| + | tcp_nodelay on; | ||
| + | keepalive_timeout 30; | ||
| + | gzip on; | ||
| + | gzip_min_length 1100; | ||
| + | gzip_comp_level | ||
| + | gzip_types | ||
| + | </ | ||
| + | |||
| + | ====== Check memory consumption for PHP-FPM ====== | ||
| + | Single process | ||
| + | < | ||
| + | ps --no-headers -o " | ||
| + | </ | ||
| + | |||
| + | |||
| + | ====== Performance no rules ====== | ||
| + | < | ||
| + | $ wrk -c 100 -t 4 -d 30s http:// | ||
| + | Running 30s test @ http:// | ||
| + | 4 threads and 100 connections | ||
| + | Thread Stats | ||
| + | Latency | ||
| + | Req/ | ||
| + | 1966522 requests in 30.09s, 474.39MB read | ||
| + | Requests/ | ||
| + | Transfer/ | ||
| + | </ | ||
| + | ====== Performance filter IP 1 rule ====== | ||
| + | < | ||
| + | $ wrk -c 100 -t 4 -d 30s http:// | ||
| + | Running 30s test @ http:// | ||
| + | 4 threads and 100 connections | ||
| + | Thread Stats | ||
| + | Latency | ||
| + | Req/ | ||
| + | 1872796 requests in 30.09s, 451.78MB read | ||
| + | Requests/ | ||
| + | Transfer/ | ||
| + | </ | ||
| + | |||
| + | ====== Performance filter IP 5000 rules ====== | ||
| + | < | ||
| + | $ wrk -c 100 -t 4 -d 30s http:// | ||
| + | Running 30s test @ http:// | ||
| + | 4 threads and 100 connections | ||
| + | Thread Stats | ||
| + | Latency | ||
| + | Req/ | ||
| + | 1636391 requests in 30.10s, 394.75MB read | ||
| + | Requests/ | ||
| + | Transfer/ | ||
| + | </ | ||
| + | |||
| + | ====== Performance filter IP 50000 rules ====== | ||
| + | < | ||
| + | $ wrk -c 100 -t 4 -d 30s http:// | ||
| + | Running 30s test @ http:// | ||
| + | 4 threads and 100 connections | ||
| + | Thread Stats | ||
| + | Latency | ||
| + | Req/ | ||
| + | 797378 requests in 30.03s, 192.35MB read | ||
| + | Requests/ | ||
| + | Transfer/ | ||
| + | </ | ||
| + | |||
| + | |||
| + | < | ||
| + | http { | ||
| + | server { | ||
| + | listen 443; | ||
| + | ssl on; | ||
| + | ssl_certificate | ||
| + | ssl_certificate_key | ||
| + | ssl_client_certificate / | ||
| + | ssl_verify_client on; | ||
| + | ssl_verify_depth 2; | ||
| + | root /var/www/; | ||
| + | |||
| + | location / { | ||
| + | if ($ssl_client_verify != SUCCESS) { return 403; } | ||
| + | autoindex on; # directory listing | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | ====== NGINX cache ====== | ||
| + | < | ||
| + | Set keepalive at upstream | ||
| + | location / { | ||
| + | proxy_http_version 1.1; | ||
| + | proxy_cache_background_update on; | ||
| + | proxy_cache_use_stale error timeout http_500; // use old when error | ||
| + | proxy_cache_min_uses 5; | ||
| + | } | ||
| + | </ | ||
| + | ===== Bypass ===== | ||
| + | < | ||
| + | location / { | ||
| + | proxy_cache cache; | ||
| + | proxy_cache_bypass $cookie_nocache $arg_nocache $http_nocache; | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | |||
| + | < | ||
| + | http{ | ||
| + | proxy_cache_path / | ||
| + | } | ||
| + | server{ | ||
| + | location ^~ /images { | ||
| + | proxy_cache cache; | ||
| + | proxy_cache_valid 200 301 302 12h; // any 1s; | ||
| + | proxy_ignore_headers Cache-Control; | ||
| + | proxy_pass http:// | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | ===== reconfigure nginx ===== | ||
| + | < | ||