Refactor nginx.conf and other ops scripts for lightning

This commit is contained in:
wiz
2022-07-06 14:01:18 +02:00
parent ec9e47233a
commit 63f4c5a003
17 changed files with 844 additions and 139 deletions

View File

@@ -1,26 +1,51 @@
location /api/v1/statistics {
try_files /dev/null @mempool-api-v1-warmcache;
}
location /api/v1/mining {
try_files /dev/null @mempool-api-v1-warmcache;
}
location /api/v1/block/ {
try_files /dev/null @mempool-api-v1-forevercache;
}
location /api/v1 {
try_files /dev/null @mempool-api-v1-coldcache;
}
location /api/block/ {
rewrite ^/api/(.*) /$1 break;
try_files /dev/null @electrs-api-forevercache;
}
location /api/ {
rewrite ^/api/(.*) /$1 break;
try_files /dev/null @electrs-api-nocache;
###########
# mempool #
###########
# websocket has special HTTP headers
location /api/v1/ws {
try_files /dev/null @mempool-api-v1-websocket;
}
location @mempool-api-v1-forevercache {
proxy_pass $mempoolBackend;
# warm cache mining and mempool API responses
location /api/v1/statistics {
try_files /dev/null @mempool-api-v1-cache-warm;
}
location /api/v1/mining {
try_files /dev/null @mempool-api-v1-cache-warm;
}
# it's ok to cache blockchain data "forever", so we do 30d
location /api/v1/block/ {
try_files /dev/null @mempool-api-v1-cache-forever;
}
# everything else gets "normal" cache
location /api/v1 {
try_files /dev/null @mempool-api-v1-cache-normal;
}
###########
# esplora #
###########
# it's ok to cache blockchain data "forever", so we do 30d
location /api/block/ {
rewrite ^/api/(.*) /$1 break;
try_files /dev/null @esplora-api-cache-forever;
}
# other API responses cannot be cached
location /api/ {
rewrite ^/api/(.*) /$1 break;
try_files /dev/null @esplora-api-cache-disabled;
}
###########
# routing #
###########
location @mempool-api-v1-websocket {
proxy_pass $mempoolMainnet;
proxy_http_version 1.1;
proxy_set_header Host $http_host;
@@ -29,8 +54,16 @@ location @mempool-api-v1-forevercache {
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header X-Forwarded-Proto $scheme;
}
location @mempool-api-v1-cache-forever {
proxy_pass $mempoolMainnet;
proxy_set_header Host $http_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_cache_bypass $http_upgrade;
proxy_cache_background_update on;
proxy_cache_use_stale updating;
proxy_cache api;
@@ -40,18 +73,14 @@ location @mempool-api-v1-forevercache {
expires 30d;
}
location @mempool-api-v1-warmcache {
proxy_pass $mempoolBackend;
proxy_http_version 1.1;
location @mempool-api-v1-cache-warm {
proxy_pass $mempoolMainnet;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header X-Forwarded-Proto $scheme;
proxy_cache_bypass $http_upgrade;
proxy_cache_background_update on;
proxy_cache_use_stale updating;
proxy_cache api;
@@ -59,18 +88,14 @@ location @mempool-api-v1-warmcache {
proxy_redirect off;
}
location @mempool-api-v1-coldcache {
proxy_pass $mempoolBackend;
proxy_http_version 1.1;
location @mempool-api-v1-cache-normal {
proxy_pass $mempoolMainnet;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header X-Forwarded-Proto $scheme;
proxy_cache_bypass $http_upgrade;
proxy_cache api;
proxy_cache_valid 200 10s;
proxy_redirect off;
@@ -78,54 +103,42 @@ location @mempool-api-v1-coldcache {
expires 10s;
}
location @mempool-api-v1-nocache {
proxy_pass $mempoolBackend;
proxy_http_version 1.1;
location @mempool-api-v1-cache-disabled {
proxy_pass $mempoolMainnet;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header X-Forwarded-Proto $scheme;
proxy_cache_bypass $http_upgrade;
proxy_redirect off;
proxy_buffering off;
expires -1;
}
location @electrs-api-nocache {
proxy_pass $electrsBackend;
proxy_http_version 1.1;
location @esplora-api-cache-disabled {
proxy_pass $esploraMainnet;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header X-Forwarded-Proto $scheme;
proxy_cache_bypass $http_upgrade;
proxy_redirect off;
proxy_buffering off;
expires -1;
}
location @electrs-api-forevercache {
proxy_pass $electrsBackend;
proxy_http_version 1.1;
location @esplora-api-cache-forever {
proxy_pass $esploraMainnet;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header X-Forwarded-Proto $scheme;
proxy_cache_bypass $http_upgrade;
proxy_cache_background_update on;
proxy_cache_use_stale updating;
proxy_cache api;