Skip to content

Instantly share code, notes, and snippets.

@posulliv
Last active September 10, 2023 14:55
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save posulliv/6c6550b8e51a5f1715bfbd9a01841d97 to your computer and use it in GitHub Desktop.
Save posulliv/6c6550b8e51a5f1715bfbd9a01841d97 to your computer and use it in GitHub Desktop.
Simple demo of Trino HA using Nginx reverse proxy.
version: '3.3'
services:
trino_a:
image: trinodb/trino
container_name: trino_a
ports:
- 8080:8080
volumes:
- ./trino_a.config.properties:/etc/trino/config.properties
- ./jvm.config:/etc/trino/jvm.config
trino_b:
image: trinodb/trino
container_name: trino_b
ports:
- 8081:8081
volumes:
- ./trino_b.config.properties:/etc/trino/config.properties
- ./jvm.config:/etc/trino/jvm.config
trino_worker:
image: trinodb/trino
container_name: trino_worker
volumes:
- ./trino_worker.config.properties:/etc/trino/config.properties
- ./jvm.config:/etc/trino/jvm.config
nginx:
image: nginx
container_name: nginx
ports:
- 80:80
volumes:
- ./nginx.conf:/etc/nginx/conf.d/default.conf
-server
-Xmx2G
-XX:+UseG1GC
-XX:+UseGCOverheadLimit
-XX:+ExplicitGCInvokesConcurrent
-XX:+HeapDumpOnOutOfMemoryError
-XX:+ExitOnOutOfMemoryError
-XX:ReservedCodeCacheSize=150M
-Duser.timezone=UTC
-Djdk.attach.allowAttachSelf=true
upstream trino {
server trino_a:8080 fail_timeout=3s max_fails=1;
server trino_b:8081 backup;
}
server {
listen 80;
server_name localhost;
location / {
proxy_pass http://trino;
proxy_redirect http://trino/ /;
proxy_connect_timeout 3;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
coordinator=true
node-scheduler.include-coordinator=true
http-server.http.port=8080
query.max-memory=1.4GB
query.max-memory-per-node=1.4GB
query.max-total-memory-per-node=1.4GB
discovery.uri=http://localhost:8080
coordinator=true
node-scheduler.include-coordinator=true
http-server.http.port=8081
query.max-memory=1.4GB
query.max-memory-per-node=1.4GB
query.max-total-memory-per-node=1.4GB
discovery.uri=http://localhost:8081
coordinator=false
query.max-memory=1.4GB
query.max-memory-per-node=1.4GB
query.max-total-memory-per-node=1.4GB
discovery.uri=http://nginx:80
@guyskk
Copy link

guyskk commented Nov 10, 2022

If expose nginx with ports (not 80 443), should use proxy_set_header Host $http_host; to make trinodb build correct urls in response. $http_host includes port and $host not includes port.

My Nginx config:

server {
    listen 8180;
    server_name _;
    chunked_transfer_encoding off;
    location / {
        allow 127.0.0.1;
        deny all;
        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_pass http://127.0.0.1:8080;
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment