Skip to content

Instantly share code, notes, and snippets.

@livioribeiro
Created January 19, 2018 10:07
Show Gist options
  • Save livioribeiro/146125a1ff8369eac2ac1550cc0c7c2b to your computer and use it in GitHub Desktop.
Save livioribeiro/146125a1ff8369eac2ac1550cc0c7c2b to your computer and use it in GitHub Desktop.
Simplest proxy to docker swarm services
# based on https://serverfault.com/questions/291703/dynamic-backends-with-haproxy/292581#292581
server {
listen 80;
server_name *.localtest.me;
#charset koi8-r;
#access_log /var/log/nginx/host.access.log main;
resolver 127.0.0.11;
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
if ($host ~ (.*?)\.localtest\.me) {
set $_service $1;
proxy_pass http://$_service$request_uri;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment