From 0d03a9e6cc3e846b2f968ef15d78ffbb29e46d28 Mon Sep 17 00:00:00 2001 From: wiz Date: Tue, 27 Apr 2021 18:58:46 +0900 Subject: [PATCH] Send HTTP header Vary: Cookie to prevent localization cache bug Fixes #477 --- nginx-mempool.conf | 5 ++++- production/nginx-mempool.conf | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/nginx-mempool.conf b/nginx-mempool.conf index 8c2f6948b..7514a6dc5 100644 --- a/nginx-mempool.conf +++ b/nginx-mempool.conf @@ -7,10 +7,11 @@ # fallback for all URLs i.e. /address/foo /tx/foo /block/000 location / { + add_header Vary Cookie; try_files /$lang/$uri /$lang/$uri/ $uri $uri/ /en-US/$uri @index-redirect; } location @index-redirect { - add_header vary accept-language; + add_header Vary Cookie; rewrite (.*) /$lang/index.html; } @@ -18,10 +19,12 @@ # used to rewrite resources from // to /en-US/ location ~ ^/(ar|bg|bs|ca|cs|da|de|et|el|es|eo|eu|fa|fr|gl|ko|hr|id|it|he|ka|lv|lt|hu|mk|ms|nl|ja|ka|no|nb|nn|pl|pt|pt-BR|ro|ru|sk|sl|sr|sh|fi|sv|th|tr|uk|vi|zh)/resources/ { + add_header Vary Cookie; rewrite ^/[a-zA-Z-]*/resources/(.*) /en-US/resources/$1; } # used for cookie override location ~ ^/(ar|bg|bs|ca|cs|da|de|et|el|es|eo|eu|fa|fr|gl|ko|hr|id|it|he|ka|lv|lt|hu|mk|ms|nl|ja|ka|no|nb|nn|pl|pt|pt-BR|ro|ru|sk|sl|sr|sh|fi|sv|th|tr|uk|vi|zh)/ { + add_header Vary Cookie; try_files $uri $uri/ /$1/index.html =404; } diff --git a/production/nginx-mempool.conf b/production/nginx-mempool.conf index b9be208a6..8a5759bd4 100644 --- a/production/nginx-mempool.conf +++ b/production/nginx-mempool.conf @@ -35,15 +35,17 @@ location / { try_files /$lang/$uri /$lang/$uri/ $uri $uri/ /en-US/$uri @index-redirect; add_header Cache-Control "public, no-transform"; + add_header Vary Cookie; expires 10m; } location /resources { try_files /$lang/$uri /$lang/$uri/ $uri $uri/ /en-US/$uri @index-redirect; add_header Cache-Control "public, no-transform"; + add_header Vary Cookie; expires 1h; } location @index-redirect { - add_header vary accept-language; + add_header Vary Cookie; rewrite (.*) /$lang/index.html; } @@ -55,6 +57,7 @@ } # used for cookie override location ~ ^/(ar|bg|bs|ca|cs|da|de|et|el|es|eo|eu|fa|fr|gl|ko|hr|id|it|he|ka|lv|lt|hu|mk|ms|nl|ja|ka|no|nb|nn|pl|pt|pt-BR|ro|ru|sk|sl|sr|sh|fi|sv|th|tr|uk|vi|zh)/ { + add_header Vary Cookie; try_files $uri $uri/ /$1/index.html =404; }