Skip to content

Instantly share code, notes, and snippets.

@kokizzu
Forked from ii64/docker-compose.yml
Created April 24, 2023 20:50
Show Gist options
  • Save kokizzu/ee7ce94e1ea3d02de83f5bbd8f4e4062 to your computer and use it in GitHub Desktop.
Save kokizzu/ee7ce94e1ea3d02de83f5bbd8f4e4062 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