2022-01-04 07:28:17 +01:00
|
|
|
# angular builds to index.html
|
|
|
|
index index.html;
|
|
|
|
|
|
|
|
# tor onion redirect
|
|
|
|
add_header Onion-Location http://$onion.onion$request_uri;
|
|
|
|
|
|
|
|
# HSTS preload enable
|
|
|
|
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload";
|
|
|
|
|
|
|
|
# generate frame configuration from origin header
|
|
|
|
set $frameOptions "DENY";
|
|
|
|
set $contentSecurityPolicy "frame-ancestors 'none'";
|
|
|
|
|
|
|
|
# used for iframes on https://mempool.space/network
|
|
|
|
if ($http_referer ~ ^https://mempool.space/)
|
|
|
|
{
|
|
|
|
set $frameOptions "ALLOW-FROM https://mempool.space";
|
|
|
|
set $contentSecurityPolicy "frame-ancestors https://mempool.space";
|
|
|
|
}
|
|
|
|
# used for iframes on https://mempool.ninja/network
|
|
|
|
if ($http_referer ~ ^https://mempool.ninja/)
|
|
|
|
{
|
|
|
|
set $frameOptions "ALLOW-FROM https://mempool.ninja";
|
|
|
|
set $contentSecurityPolicy "frame-ancestors https://mempool.ninja";
|
|
|
|
}
|
|
|
|
# used for iframes on https://wiz.biz/bitcoin/nodes
|
|
|
|
if ($http_referer ~ ^https://wiz.biz/)
|
|
|
|
{
|
|
|
|
set $frameOptions "ALLOW-FROM https://wiz.biz";
|
|
|
|
set $contentSecurityPolicy "frame-ancestors https://wiz.biz";
|
|
|
|
}
|
|
|
|
|
|
|
|
# restrict usage of frames
|
|
|
|
add_header X-Frame-Options $frameOptions;
|
|
|
|
add_header Content-Security-Policy $contentSecurityPolicy;
|
|
|
|
|
|
|
|
# enable browser and proxy caching
|
2022-01-12 15:12:49 +01:00
|
|
|
add_header Pragma "public";
|
|
|
|
add_header Cache-Control "public";
|
2022-01-04 07:28:17 +01:00
|
|
|
|
|
|
|
# vary cache if user changes language preference
|
|
|
|
add_header Vary Accept-Language;
|
|
|
|
add_header Vary Cookie;
|
|
|
|
|
2022-01-12 15:12:49 +01:00
|
|
|
# see order of nginx location rules
|
|
|
|
# https://stackoverflow.com/questions/5238377/nginx-location-priority
|
|
|
|
|
|
|
|
# for exact / requests, redirect based on $lang
|
2022-01-14 14:22:57 +01:00
|
|
|
# cache redirect for 10 minutes
|
2022-01-12 15:12:49 +01:00
|
|
|
location = / {
|
|
|
|
if ($lang != '') {
|
|
|
|
return 302 $scheme://$host/$lang$uri;
|
|
|
|
}
|
|
|
|
try_files /en-US/index.html =404;
|
2022-01-04 07:28:17 +01:00
|
|
|
expires 10m;
|
|
|
|
}
|
|
|
|
|
|
|
|
# used to rewrite resources from /<lang>/ to /en-US/
|
2022-01-14 14:22:57 +01:00
|
|
|
# cache /resources/** for 1 week since they don't change often
|
2022-01-12 15:12:49 +01:00
|
|
|
location ~ ^/[a-z][a-z]/resources/(.*) {
|
|
|
|
try_files $uri /en-US/resources/$1 =404;
|
|
|
|
expires 1w;
|
2022-01-04 07:28:17 +01:00
|
|
|
}
|
2022-01-14 14:22:57 +01:00
|
|
|
# cache /<lang>/main.f40e91d908a068a2.js forever since they never change
|
|
|
|
location ~ ^/([a-z][a-z])/(.+\..+\.(js|css)) {
|
|
|
|
try_files $uri =404;
|
|
|
|
expires 1y;
|
|
|
|
}
|
|
|
|
# cache everything else for 10 minutes
|
2022-01-12 15:12:49 +01:00
|
|
|
location ~ ^/([a-z][a-z])$ {
|
|
|
|
try_files $uri /$1/index.html /en-US/index.html =404;
|
|
|
|
expires 10m;
|
|
|
|
}
|
|
|
|
location ~ ^/([a-z][a-z])/ {
|
|
|
|
try_files $uri /$1/index.html /en-US/index.html =404;
|
|
|
|
expires 10m;
|
|
|
|
}
|
|
|
|
|
2022-01-14 14:22:57 +01:00
|
|
|
# cache /resources/** for 1 week since they don't change often
|
2022-01-12 15:12:49 +01:00
|
|
|
location /resources {
|
|
|
|
try_files $uri /en-US/$uri /en-US/index.html;
|
|
|
|
expires 1w;
|
|
|
|
}
|
2022-01-14 14:22:57 +01:00
|
|
|
# cache /main.f40e91d908a068a2.js forever since they never change
|
|
|
|
location ~* ^/.+\..+\.(js|css) {
|
|
|
|
try_files /$lang/$uri /en-US/$uri =404;
|
|
|
|
expires 1y;
|
|
|
|
}
|
|
|
|
# catch-all for all URLs i.e. /address/foo /tx/foo /block/000
|
|
|
|
# cache 10 minutes since they change frequently
|
2022-01-12 15:12:49 +01:00
|
|
|
location / {
|
|
|
|
try_files /$lang/$uri $uri /en-US/$uri /en-US/index.html =404;
|
|
|
|
expires 10m;
|
2022-01-04 09:27:37 +01:00
|
|
|
}
|