Skip to content

Commit

Permalink
Fix chaching and rewrite locations
Browse files Browse the repository at this point in the history
  • Loading branch information
robertdijk committed Sep 16, 2024
1 parent 8e30e68 commit 4ca4cfd
Showing 1 changed file with 20 additions and 27 deletions.
47 changes: 20 additions & 27 deletions nginx.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
proxy_cache_path /var/nginx/cache keys_zone=mycache:10m;
proxy_cache_path /var/nginx/cache keys_zone=default_cache:10m max_size=2g;
server {
listen 8080;
listen [::]:8080;
Expand All @@ -7,12 +7,22 @@ server {

server_name localhost;

proxy_cache mycache;
proxy_cache default_cache;
proxy_cache_key $scheme$proxy_host$uri;

proxy_ignore_headers "Set-Cookie";
proxy_hide_header "Set-Cookie";
proxy_buffering on;

proxy_cache_key $scheme$proxy_host$uri;
proxy_ignore_headers Expires;
proxy_ignore_headers X-Accel-Expires;
proxy_ignore_headers Cache-Control;
proxy_ignore_headers Set-Cookie;

proxy_hide_header X-Accel-Expires;
proxy_hide_header Expires;
proxy_hide_header Cache-Control;
proxy_hide_header Pragma;

add_header X-Proxy-Cache $upstream_cache_status;

location = /health {
access_log off;
Expand All @@ -24,41 +34,24 @@ server {
return 302 /public;
}

location /login {
return 404;
}

location /register {
return 404;
}

location /jury {
location ~ ^/(login|register|jury|team) {
return 404;
}

location /team {
return 404;
}

location /images {
proxy_cache_valid any 10m;
proxy_pass ${DOMJUDGE_URL}/images;
}

location /flags {
location ~ ^/((images|flags|css|js|style_domjudge.css|webfonts|favicon.ico).*) {
proxy_cache_valid any 10m;
proxy_pass ${DOMJUDGE_URL}/flags;
proxy_pass ${DOMJUDGE_URL}/$1;
}

location / {
proxy_set_header Accept-Encoding "";

sub_filter '<a class="btn btn-info btn-sm justify-content-center" href="/login">\n' '';
sub_filter '<i class="fas fa-sign-in-alt"></i> Login\n' '';
sub_filter_once off;

set $args $args&static=yes;

proxy_set_header Accept-Encoding "";

proxy_cache_valid any 1m;
proxy_pass ${DOMJUDGE_URL};
}
Expand Down

0 comments on commit 4ca4cfd

Please sign in to comment.