2023-08-29 16:32:37 +00:00
|
|
|
server {
|
|
|
|
listen 80;
|
|
|
|
server_name my.example.com;
|
|
|
|
|
|
|
|
# See: https://github.com/acmesh-official/acme.sh/wiki/Stateless-Mode
|
|
|
|
# and https://datatracker.ietf.org/doc/html/rfc8555
|
|
|
|
location ~ ^/\.well-known/acme-challenge/([-_a-zA-Z0-9]+)$ {
|
|
|
|
default_type text/plain;
|
|
|
|
return 200 "$1.MY_ACCOUNT_THUMBPRINT_GOES_HERE";
|
|
|
|
}
|
|
|
|
|
|
|
|
location / {
|
|
|
|
return 301 https://$host$request_uri;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
upstream geth-pool {
|
2023-10-25 19:42:52 +00:00
|
|
|
server server-a:8545 max_fails=10 fail_timeout=2s;
|
|
|
|
server server-c:8545 max_fails=10 fail_timeout=2s backup;
|
|
|
|
server server-b:8545 max_fails=10 fail_timeout=2s backup;
|
|
|
|
keepalive 200;
|
2023-08-29 16:32:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
upstream reg-ui-pool {
|
2023-10-25 19:42:52 +00:00
|
|
|
keepalive 2;
|
2023-08-29 16:32:37 +00:00
|
|
|
server server-a:8085;
|
|
|
|
}
|
|
|
|
|
|
|
|
upstream reg-api-pool {
|
2023-10-25 19:42:52 +00:00
|
|
|
keepalive 2;
|
2023-08-29 16:32:37 +00:00
|
|
|
server server-a:8086;
|
|
|
|
}
|
|
|
|
|
2023-10-25 19:42:52 +00:00
|
|
|
# auth uses the reg server when available
|
2023-08-29 16:32:37 +00:00
|
|
|
upstream auth-pool {
|
2023-10-25 19:42:52 +00:00
|
|
|
keepalive 10;
|
2023-08-29 16:32:37 +00:00
|
|
|
server server-a:8080;
|
|
|
|
server server-b:8080 backup;
|
|
|
|
server server-c:8080 backup;
|
|
|
|
}
|
|
|
|
|
2023-10-25 19:42:52 +00:00
|
|
|
|
|
|
|
log_format upstreamlog '[$time_local] $msec $remote_addr $user_id - $server_name($host) to $upstream_addr: $request $status upstream_response_time $upstream_response_time request_time $request_time';
|
|
|
|
proxy_cache_path /var/cache/nginx/auth_cache levels=1 keys_zone=auth_cache:1m max_size=5m inactive=60m;
|
|
|
|
|
2023-08-29 16:32:37 +00:00
|
|
|
server {
|
|
|
|
listen 443 ssl http2;
|
|
|
|
server_name my.example.com;
|
2023-10-25 19:42:52 +00:00
|
|
|
keepalive_requests 500000;
|
|
|
|
keepalive_timeout 90s;
|
|
|
|
http2_max_requests 5000000;
|
|
|
|
http2_max_concurrent_streams 1024;
|
|
|
|
http2_idle_timeout 3m;
|
|
|
|
http2_recv_timeout 30s;
|
2023-08-29 16:32:37 +00:00
|
|
|
access_log /var/log/nginx/my.example.com-access.log upstreamlog;
|
|
|
|
error_log /var/log/nginx/my.example.com-error.log;
|
|
|
|
|
|
|
|
ssl_certificate /etc/nginx/ssl/my.example.com/cert.pem;
|
|
|
|
ssl_certificate_key /etc/nginx/ssl/my.example.com/key.pem;
|
2023-10-25 19:42:52 +00:00
|
|
|
ssl_session_cache shared:SSL:10m;
|
2023-08-29 16:32:37 +00:00
|
|
|
|
|
|
|
error_page 500 502 503 504 /50x.html;
|
|
|
|
location = /50x.html {
|
|
|
|
root /usr/share/nginx/html;
|
|
|
|
}
|
|
|
|
|
|
|
|
#rewrite ^/?$ /newuser/;
|
|
|
|
rewrite ^/?$ https://www.example.com/;
|
|
|
|
|
|
|
|
# geth-pool ETH API
|
|
|
|
location ~ ^/v1/eth/?([^/]*)$ {
|
|
|
|
set $apiKey $1;
|
|
|
|
if ($apiKey = '') {
|
|
|
|
set $apiKey $http_X_API_KEY;
|
|
|
|
}
|
|
|
|
auth_request /auth;
|
|
|
|
auth_request_set $user_id $sent_http_x_user_id;
|
|
|
|
rewrite /.*$ / break;
|
|
|
|
|
2023-10-25 19:42:52 +00:00
|
|
|
client_max_body_size 3m;
|
|
|
|
client_body_buffer_size 3m;
|
2023-08-29 16:32:37 +00:00
|
|
|
proxy_buffer_size 32k;
|
|
|
|
proxy_buffers 16 32k;
|
|
|
|
proxy_busy_buffers_size 96k;
|
|
|
|
|
|
|
|
proxy_pass http://geth-pool;
|
|
|
|
proxy_set_header X-Original-Remote-Addr $remote_addr;
|
|
|
|
proxy_set_header X-User-Id $user_id;
|
2023-10-25 19:42:52 +00:00
|
|
|
proxy_http_version 1.1;
|
|
|
|
proxy_set_header Connection "";
|
2023-08-29 16:32:37 +00:00
|
|
|
}
|
2023-10-25 19:42:52 +00:00
|
|
|
|
2023-08-29 16:32:37 +00:00
|
|
|
# keycloak
|
|
|
|
location = /auth {
|
|
|
|
internal;
|
|
|
|
proxy_cache auth_cache;
|
|
|
|
proxy_cache_key "$apiKey";
|
|
|
|
proxy_cache_valid 200 300s;
|
|
|
|
proxy_cache_valid 401 30s;
|
|
|
|
proxy_pass http://auth-pool/auth/realms/cerc/check?memberOf=eth&apiKey=$apiKey;
|
|
|
|
proxy_pass_request_body off;
|
|
|
|
proxy_set_header Content-Length "";
|
|
|
|
proxy_set_header X-Original-URI $request_uri;
|
|
|
|
proxy_set_header X-Original-Remote-Addr $remote_addr;
|
|
|
|
proxy_set_header X-Original-Host $host;
|
2023-10-25 19:42:52 +00:00
|
|
|
proxy_http_version 1.1;
|
|
|
|
proxy_set_header Connection "";
|
2023-08-29 16:32:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
location /newuser/ {
|
|
|
|
proxy_pass http://reg-ui-pool/;
|
|
|
|
}
|
|
|
|
|
|
|
|
location /user-api/ {
|
|
|
|
proxy_pass http://reg-api-pool/;
|
|
|
|
}
|
|
|
|
}
|