Skip to content

Commit

Permalink
Merge pull request #424 from yetanalytics/proxy_example
Browse files Browse the repository at this point in the history
proxy example with addtl path
  • Loading branch information
cliffcaseyyet authored Sep 17, 2024
2 parents ee70727 + 7be36a8 commit 21b5bc9
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 0 deletions.
64 changes: 64 additions & 0 deletions dev-resources/proxied_example/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
version: "3.9"
# README:
# Runs a SQL LRS container and a proxy (nginx) which serves the LRS on a special path (/foo).

# To run:
# 1. From the load_balanced dir: docker compose up
# 2. Access on port 8083 in your browser.

# See the Docker Compose docs for more info: https://docs.docker.com/compose/
configs:
px_config:
file: ./nginx.conf

volumes:
db_data:

services:
db:
image: postgres
volumes:
- db_data:/var/lib/postgresql/data
environment:
POSTGRES_USER: lrsql_user
POSTGRES_PASSWORD: lrsql_password
POSTGRES_DB: lrsql_db
lrs:
# build: ../.. # switch to this for active dev
image: yetanalytics/lrsql:latest
command:
- /lrsql/bin/run_postgres.sh
ports:
- "8080:8080"
depends_on:
- db
healthcheck:
test: wget --no-verbose --tries=1 --spider http://localhost:8080/health || exit 1
interval: 5s
timeout: 5s
retries: 10
environment:
LRSQL_API_KEY_DEFAULT: my_key
LRSQL_API_SECRET_DEFAULT: my_secret
LRSQL_ADMIN_USER_DEFAULT: my_username
LRSQL_ADMIN_PASS_DEFAULT: my_password
LRSQL_ALLOW_ALL_ORIGINS: "true"
#NOTE: this path var is needed to inform the frontend behavior once the app is proxied
LRSQL_PROXY_PATH: /foo
LRSQL_DB_HOST: db
LRSQL_DB_NAME: lrsql_db
LRSQL_DB_USER: lrsql_user
LRSQL_DB_PASSWORD: lrsql_password
# If Postgres is too slow to start, increase this
LRSQL_POOL_INITIALIZATION_FAIL_TIMEOUT: 10000
LRSQL_JWT_COMMON_SECRET: sandwich #in production, this should be between 32 and 64 chars for security
proxy:
image: nginx:stable-alpine
configs:
- source: px_config
target: /etc/nginx/conf.d/default.conf
ports:
- "8083:8083"
depends_on:
lrs:
condition: service_healthy
16 changes: 16 additions & 0 deletions dev-resources/proxied_example/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
upstream backend {
server lrs:8080;
}

server {
listen 8083;

include /etc/nginx/mime.types;

location /foo {
rewrite /foo/(.*) /$1 break;
proxy_pass http://backend/;
proxy_redirect off;
proxy_set_header Host $host;
}
}

0 comments on commit 21b5bc9

Please sign in to comment.