Skip to content

Commit

Permalink
Merge pull request #410 from WikipediaLibrary/kgraessle/fix-nginx-nes…
Browse files Browse the repository at this point in the history
…ting

Fix the directive location to be nested so that it inherits parent di…
  • Loading branch information
jsnshrmn authored Dec 11, 2024
2 parents b73e179 + cc8a900 commit ece86c1
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -74,20 +74,37 @@ server {
if ($http_user_agent ~* (GoogleBot|bingbot|YandexBot|mj12bot|Apache-HttpClient|Adsbot|Barkrowler|FacebookBot|dotbot|Bytespider|SemrushBot|AhrefsBot|Amazonbot|GPTBot) ) {
return 403;
}

location /admin/links/ {
try_files $uri @django-admin-slow;
}
# checks for static file, if not found proxy to app
try_files $uri @django;
}
location /admin/links/ {
location @django {
# Cache
proxy_cache_valid 200 301 302 401 403 404 1d;
proxy_cache_bypass $http_pragma $no_cache_method $no_cache_control $no_cache_session;
proxy_cache_revalidate on;
proxy_cache cache;
add_header X-Cache-Status $upstream_cache_status;
# Rate limit
limit_req zone=bots burst=2 nodelay;
limit_req zone=one burst=1000 nodelay;
limit_req_status 429;
# Proxy
proxy_set_header X-Forwarded-Proto $web_proxy_scheme;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://django_server;
}
location @django-admin-slow {
# https://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_send_timeout
proxy_connect_timeout 120s;
proxy_send_timeout 120s;
proxy_read_timeout 120s;
# https://nginx.org/en/docs/http/ngx_http_core_module.html#send_timeout
send_timeout 120s;
keepalive_timeout 120s;
}
location @django {
# Cache
proxy_cache_valid 200 301 302 401 403 404 1d;
proxy_cache_bypass $http_pragma $no_cache_method $no_cache_control $no_cache_session;
Expand Down

0 comments on commit ece86c1

Please sign in to comment.