gzip_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript application/vnd.ms-fontobject application/x-font-ttf font/opentype image/svg+xml image/x-icon; #based on cache enable or disable the cache # map $http_cookie $no_cache { # default 0; # ~SESS 1; # PHP session # ~SSESS 1; # PHP session # } # # # #based on uri disable the cache # map $uri $nouricache { # default 0; # /search 1; # /user/login 1; # /user/register 1; # /apis 1; # /search-api 1; # } # map $http_cache_purge $bypass { default 0; true 1; } proxy_cache_path /var/www/nginx/cache/content levels=1:2 keys_zone=testnginx:100m max_size=20g inactive=2d use_temp_path=off loader_threshold=300 loader_files=200; proxy_cache_path /var/www/nginx/cache/files levels=1:2 keys_zone=testnginxfiles:10m max_size=20g inactive=2d use_temp_path=off loader_threshold=300 loader_files=200; #proxy_store_access group:rw; server { listen 80; server_name testnginxproxycachepurge.testintcraft.com; add_header Access-Control-Allow-Origin *; return 301 https://$server_name$request_uri; # set $bypass 0; # if ($remote_addr ~ "^(127.0.0.1)$") { # set $bypass $http_cache_purge; #set $bypass $http_secret_header; #} } server { listen 443 ssl; server_name testnginxproxycachepurge.testintcraft.com; ssl_protocols TLSv1.3 TLSv1.2; ssl_certificate /etc/letsencrypt/live/testnginxproxycachepurge.testintcraft.com/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/testnginxproxycachepurge.testintcraft.com/privkey.pem; ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384; ssl_prefer_server_ciphers on; # set $bypass 0; set $bypass 0; if ($remote_addr ~ "^(127.0.0.1)$") { set $bypass $http_cache_purge; # security for bypass so localhost can empty cache # if ($remote_addr ~ "^(127.0.0.1)$") { # set $bypass $http_secret_header; } error_log /var/log/nginx/error.log debug; proxy_intercept_errors on; error_page 500 /error-500.html; location = /error-500.html { root /var/www/html/gsma/oneapimarketplace/servererrorpages/error-pages-500-503/html; } error_page 503 /error-503.html; location = /error-503.html { root /var/www/html/gsma/oneapimarketplace/servererrorpages/error-pages-500-503/html; } if ($request_uri ~* "^(.*/)index\.php$") { return 301 $1; } location /solr { proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_pass "https://localhost:8983"; } location / { add_header Access-Control-Allow-Origin *; proxy_pass http://127.0.0.1:8080; #proxy_cache_purge PURGE from 127.0.0.1; #proxy_cache_bypass $bypass; proxy_http_version 1.1; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; #proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Forwarded-Host $host; #proxy_set_header X-Forwarded-Port $server_port; proxy_set_header X-Forwarded-Proto https; proxy_set_header X-Forwarded-Port 443; proxy_hide_header X-Powered-By; proxy_hide_header X-Generator; proxy_hide_header X-Drupal-Cache; proxy_hide_header X-Drupal-Dynamic-Cache; proxy_hide_header Server; proxy_store_access group:rw; #page caching configuration proxy_ignore_headers Vary; proxy_ignore_headers Set-Cookie; proxy_cache testnginx; proxy_cache_key $scheme$request_method$proxy_host$request_uri; #if any string parameter is 1 then page won't be cache #proxy_cache_bypass $no_cache $nouricache; #proxy_no_cache $no_cache $nouricache; #expires 1d; proxy_cache_min_uses 1; proxy_cache_valid 200 2d; proxy_cache_use_stale error timeout invalid_header updating http_500 http_502 http_503 http_504; add_header X-Cache-Status $upstream_cache_status; } location ~* \.(?:ico|css|js|gif|jpe?g|png|svg|mp4|ogg|ogv|webm|htc)$ { expires 7d; add_header Vary Accept-Encoding; access_log off; proxy_cache testnginxfiles; proxy_pass http://127.0.0.1:8080; proxy_http_version 1.1; proxy_cache_lock on; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Forwarded-Host $host; proxy_set_header X-Forwarded-Port $server_port; add_header X-Cache-Status $upstream_cache_status$scheme$proxy_host$uri$is_args$args; } location ^~ /index.php { rewrite ^/index.php(.*)$ $1 permanent; } }