1+ # Set worker processes to auto for optimal CPU core utilization
12worker_processes auto;
23
34events {
4- worker_connections 64;
5+ # Increase worker_connections for better concurrency handling
6+ worker_connections 1024;
7+ # Enable epoll for better performance on Linux systems
8+ use epoll;
59}
610
711# this must be consistent with daemondo's --pidfile specification
@@ -14,9 +18,17 @@ http {
1418 # access_log /opt/local/var/log/nginx/access-adblock2privoxy.log;
1519 access_log /dev/null;
1620
17- # avoid error 413 Request Entity Too Large
18- # client_max_body_size 64M;
19- keepalive_timeout 65;
21+ # Increase client_max_body_size to handle larger requests, uncommented for clarity
22+ client_max_body_size 64M;
23+ # Optimize keepalive_timeout for better connection reuse
24+ keepalive_timeout 65s;
25+ # Enable keepalive to upstream servers
26+ keepalive_requests 100;
27+
28+ # Improve performance with sendfile and tcp_nopush
29+ sendfile on;
30+ tcp_nopush on;
31+ tcp_nodelay on;
2032
2133 server {
2234 listen ${NGINX_PORT};
@@ -28,11 +40,15 @@ http {
2840 ssl_certificate_key /usr/local/etc/privoxy/CA/nginx.pem;
2941 # use modern crypto
3042 # https://ssl-config.mozilla.org
31- ssl_protocols TLSv1.3;
32- ssl_ecdh_curve X25519:prime256v1:secp384r1;
43+ ssl_protocols TLSv1.3 TLSv1.2; # Include TLSv1.2 for broader compatibility
44+ ssl_ecdh_curve X25519:prime256v1:secp384r1:secp521r1 ;
3345 ssl_prefer_server_ciphers off;
34- # HSTS (ngx_http_headers_module is required) (63072000 seconds)
35- add_header Strict-Transport-Security "max-age=63072000" always;
46+ # Enable session resumption for performance
47+ ssl_session_cache shared:SSL:10m;
48+ ssl_session_timeout 1d;
49+ ssl_session_tickets off; # Disable session tickets for security
50+ # HSTS for 2 years, including subdomains
51+ add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload" always;
3652
3753 #root = --webDir parameter value
3854 root /usr/local/etc/adblock2privoxy/css;
4864
4965 location ~ ^/@blackhole {
5066 default_type text/html;
67+ add_header Content-Security-Policy "default-src 'none'; style-src 'self';";
5168 return 200 "<!DOCTYPE html>\n<html>\n<head>\n<meta charset='utf-8'>\n</head>\n<body>\n<p><a href=\"https://github.com/essandess/adblock2privoxy\">adblock2privoxy</a> blackhole 🕳</p>\n</body>\n</html>\n";
5269 # rewrite ^ /default.html break;
5370 }
@@ -56,13 +73,15 @@ http {
5673 # ab2p.css in top-level directory
5774 default_type text/css;
5875 add_header X-Content-Type-Options nosniff;
76+ add_header Cache-Control "public, max-age=31536000, immutable";
5977 try_files $uri $1;
6078 }
6179
6280 location ~ ^/[^/.]+\..+/ab2p\.css$ {
6381 # first reverse domain names order
6482 default_type text/css;
6583 add_header X-Content-Type-Options nosniff;
84+ add_header Cache-Control "public, max-age=31536000, immutable";
6685 rewrite ^/([^/]*?)\.([^/.]+)(?:\.([^/.]+))?(?:\.([^/.]+))?(?:\.([^/.]+))?(?:\.([^/.]+))?(?:\.([^/.]+))?(?:\.([^/.]+))?(?:\.([^/.]+))?/ab2p.css$ /$9/$8/$7/$6/$5/$4/$3/$2/$1/ab2p.css last;
6786 }
6887
7190 # if it is unavailable - get CSS for parent domain
7291 default_type text/css;
7392 add_header X-Content-Type-Options nosniff;
93+ add_header Cache-Control "public, max-age=31536000, immutable";
7494 try_files $uri $1ab2p.css;
7595 }
7696 }
0 commit comments