Testnet & Mainnet support out of the box

This commit is contained in:
Wietse Wind
2023-10-29 01:40:26 +02:00
parent 2a733dbd5d
commit 149bba85bd
3 changed files with 213 additions and 25 deletions

View File

@@ -37,19 +37,25 @@ http {
default 0;
}
upstream backend {
server xpop:3000;
upstream backend-testnet {
server xpop-testnet:3000;
keepalive 32;
}
upstream backend-mainnet {
server xpop-mainnet:3000;
keepalive 32;
}
# TESTNET
server {
# The config below is for http (non SSL)
listen 3000;
listen [::]:3000;
listen $PUBLIC_PORT_TESTNET;
listen [::]:$PUBLIC_PORT_TESTNET;
# The config below is for SSL (https)
listen 3443 ssl;
listen [::]:3443 ssl;
listen $SSLPORT_TESTNET ssl;
listen [::]:$SSLPORT_TESTNET ssl;
ssl_session_timeout 5m;
ssl_ciphers ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:RSA+AES:!ADH:!AECDH:!MD5:!DSS;
@@ -107,7 +113,7 @@ http {
}
location / {
proxy_pass http://backend;
proxy_pass http://backend-testnet;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
@@ -120,14 +126,86 @@ http {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-No-Cors 1;
}
} # END: server {}
# error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
# error_page 500 502 503 504 /50x.html;
# location = /50x.html {
# root /usr/share/nginx/html;
# }
# MAINNET
server {
# The config below is for http (non SSL)
listen $PUBLIC_PORT;
listen [::]:$PUBLIC_PORT;
# The config below is for SSL (https)
listen $SSLPORT ssl;
listen [::]:$SSLPORT ssl;
ssl_session_timeout 5m;
ssl_ciphers ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:RSA+AES:!ADH:!AECDH:!MD5:!DSS;
ssl_protocols TLSv1.2;
ssl_prefer_server_ciphers on;
ssl_session_cache shared:SSL:10m;
resolver 1.1.1.1 8.8.8.8 [2606:4700::1111] [2606:4700:4700::1001] valid=300s ipv6=on;
resolver_timeout 5s;
ssl_stapling on;
ssl_stapling_verify on;
add_header Strict-Transport-Security "max-age=31536000; includeSubdomains;";
ssl_certificate_key /etc/nginx/ssl/nginx-ssl-private.key;
ssl_certificate /etc/nginx/ssl/nginx-ssl-certificate.pem;
ssl_dhparam /etc/nginx/ssl/dhparam.pem;
# Regular config
server_name _;
autoindex_format html;
add_header Access-Control-Allow-Origin *;
try_files $uri $uri/ =404;
absolute_redirect off;
location /healthcheck {
return 200 'Hi there!';
add_header Content-Type text/plain;
}
location /xpop {
root /usr/share/nginx/html;
autoindex off;
}
if ($http_content_type ~* json) {
set $json_request 1;
}
location ~ ^/json(/.*)?$ {
internal;
alias /usr/share/nginx/html$1; # Point to the same root as the previous location
autoindex on;
autoindex_format json;
}
location ~* ^/[0-9]+ {
root /usr/share/nginx/html;
autoindex on;
if ($is_json_request = 1) {
rewrite ^ /json$request_uri? last;
}
}
location / {
proxy_pass http://backend-mainnet;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_cache off;
proxy_buffering off;
# Configuration for LongPolling or if your KeepAliveInterval is longer than 60 seconds
proxy_read_timeout 100s;
proxy_set_header Host $host;
proxy_set_header X-Incoming-Scheme $scheme;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-No-Cors 1;
}
} # END: server {}
}