64 lines
2.4 KiB
Nginx Configuration File
64 lines
2.4 KiB
Nginx Configuration File
worker_processes 1;
|
|
pid /tmp/nginx.pid;
|
|
error_log /dev/stderr warn;
|
|
events { worker_connections 512; }
|
|
http {
|
|
access_log off;
|
|
server_tokens off;
|
|
client_body_temp_path /tmp/client_temp;
|
|
proxy_temp_path /tmp/proxy_temp;
|
|
fastcgi_temp_path /tmp/fastcgi_temp;
|
|
uwsgi_temp_path /tmp/uwsgi_temp;
|
|
scgi_temp_path /tmp/scgi_temp;
|
|
resolver ${DNS_RESOLVER} valid=10s ipv6=off;
|
|
upstream mempool_backend {
|
|
zone mempool_backend 64k;
|
|
server mempool-api:8999 resolve;
|
|
}
|
|
server {
|
|
listen 8080;
|
|
client_max_body_size 4m;
|
|
proxy_connect_timeout 5s;
|
|
proxy_read_timeout 60s;
|
|
proxy_send_timeout 30s;
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Host $host;
|
|
proxy_set_header Connection "";
|
|
proxy_set_header Authorization "";
|
|
proxy_set_header Cookie "";
|
|
proxy_hide_header Access-Control-Allow-Origin;
|
|
add_header Access-Control-Allow-Origin '*' always;
|
|
add_header Access-Control-Allow-Methods 'GET, HEAD, POST, OPTIONS' always;
|
|
add_header Access-Control-Allow-Headers 'Content-Type' always;
|
|
add_header Cache-Control 'no-store' always;
|
|
if ($request_method = OPTIONS) { return 204; }
|
|
# Mempool's backend uses /api/v1. Match its frontend's shorter /api
|
|
# surface too, without doubling already-versioned Angor URLs.
|
|
rewrite ^/api/(?!v1/)(.*)$ /api/v1/$1 last;
|
|
location = / {
|
|
default_type application/json;
|
|
return 200 '{"service":"Angor Indexer","network":"mainnet","api":"/api/v1","health":"/health"}\n';
|
|
}
|
|
# Readiness checks the indexing backend, not this gateway's process.
|
|
location = /health {
|
|
limit_except GET { deny all; }
|
|
proxy_pass http://mempool_backend/api/v1/blocks/tip/height;
|
|
proxy_intercept_errors on;
|
|
error_page 500 502 503 504 =503 @waiting;
|
|
}
|
|
location @waiting {
|
|
default_type application/json;
|
|
return 503 '{"status":"waiting","message":"Waiting for Bitcoin and Mempool indexing"}\n';
|
|
}
|
|
location ~ ^/api/(v1/)?tx$ {
|
|
limit_except GET POST { deny all; }
|
|
proxy_pass http://mempool_backend;
|
|
}
|
|
location /api/ {
|
|
limit_except GET { deny all; }
|
|
proxy_pass http://mempool_backend;
|
|
}
|
|
location / { return 404; }
|
|
}
|
|
}
|