Skip to content

Instantly share code, notes, and snippets.

@iaverin
Last active July 28, 2026 13:59
Show Gist options
  • Select an option

  • Save iaverin/eb4f0a2ca1d91bfcfbe794f390ca6407 to your computer and use it in GitHub Desktop.

Select an option

Save iaverin/eb4f0a2ca1d91bfcfbe794f390ca6407 to your computer and use it in GitHub Desktop.
Coolify second server reverse proxy
version: '3.8'
services:
nginx-proxy:
image: nginx:alpine
container_name: nginx-subdomain-forwarder
environment:
# 1. Custom variables to set in Coolify
- TARGET_DOMAIN=subdomain.domain.com
- SECOND_SERVER_IP=192.168.1.100 # Укажите ваш IP
# 2. Internal coolify variable
- COOLIFY_CONTAINER_SETTING_LABELS=true
entrypoint: >
sh -c "
mkdir -p /etc/nginx/templates &&
echo '
events { worker_connections 1024; }
http {
server {
listen 80;
server_name *.\${TARGET_DOMAIN};
location / {
proxy_pass http://\${SECOND_SERVER_IP}:80;
proxy_set_header Host \$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_http_version 1.1;
proxy_set_header Upgrade \$http_upgrade;
proxy_set_header Connection \"upgrade\";
client_max_body_size 100M;
}
}
}' > /etc/nginx/templates/nginx.conf.template &&
exec /docker-entrypoint.sh nginx -g 'daemon off;'
"
labels:
- "traefik.enable=true"
- "traefik.http.routers.nginx-subdomain.rule=HostRegexp(`{subdomain:.+}.${TARGET_DOMAIN}`)"
- "traefik.http.routers.nginx-subdomain.entrypoints=websecure"
- "traefik.http.routers.nginx-subdomain.tls=true"
- "traefik.http.services.nginx-subdomain.loadbalancer.server.port=80"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment