Skip to content

Instantly share code, notes, and snippets.

@ii64
Created April 23, 2023 11:32
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ii64/96558ca5a2d3700199b0c2dfcc0728ca to your computer and use it in GitHub Desktop.
Save ii64/96558ca5a2d3700199b0c2dfcc0728ca to your computer and use it in GitHub Desktop.
Unpopular docker compose YAML template
version: '3'
x-tpl-nginx-lb: &tpl-nginx-lb
image: nginx:stable-alpine
restart: unless-stopped
expose: [ 80 ]
entrypoint:
- sh
- -c
- |
cat << EOF > /etc/nginx/conf.d/default.conf
map \$$http_upgrade \$$connection_upgrade {
default upgrade;
'' close;
}
upstream backend {
$$UPSTREAM_BACKEND
}
server {
listen 80;
listen [::]:80;
server_name _;
location / {
proxy_pass http://backend;
proxy_set_header X-Infra-Forwarder-Host "$$HOSTNAME";
proxy_set_header X-Infra-Forwarder-Request-ID \$$request_id;
proxy_set_header X-Forwarded-Host \$$host;
proxy_set_header X-Forwarded-For \$$proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP \$$remote_addr;
proxy_set_header Host \$$host;
proxy_set_header Upgrade \$$http_upgrade;
proxy_set_header Connection \$$connection_upgrade;
set_real_ip_from 192.168.60.0/24;
set_real_ip_from 192.168.63.0/24;
real_ip_header X-Real-IP;
real_ip_recursive on;
}
}
EOF
/docker-entrypoint.sh "nginx" "-g" "daemon off;"
networks:
infra-core:
driver: bridge
ipam:
driver: default
config:
- subnet: 192.168.63.0/24
gateway: 192.168.63.1
services:
mimir-lb:
<<: *tpl-nginx-lb
environment:
- |
UPSTREAM_BACKEND=
server mimir-1:8080;
server mimir-2:8080;
networks:
- infra-core
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment