Skip to content

Instantly share code, notes, and snippets.

@ebuildy
Created February 6, 2018 20:19
Show Gist options
  • Save ebuildy/c20fd9124730b535dddffa7b9e6946ca to your computer and use it in GitHub Desktop.
Save ebuildy/c20fd9124730b535dddffa7b9e6946ca to your computer and use it in GitHub Desktop.
Use Socat to support multiple backend with jwilder/nginx-proxy

Problem from nginx-proxy/nginx-proxy#59, you cannot setup multiple backend for one container.

The solution here, is to use socat as an HTTP proxy.

My use case is "I setup a Apache Spark cluster, I want to access to web UI of master and worker".

version: "2"
services:
front:
image: jwilder/nginx-proxy
ports:
- 80:80
volumes:
- /var/run/docker.sock:/tmp/docker.sock:ro
spark-master:
image: qwant/djobi-spark
build: devops/services/spark
environment:
SPARK_MASTER_IP: "spark-master"
DJOBI_ROOT_PATH: "/opt/qwant/djobi"
VIRTUAL_HOST: "spark.*"
VIRTUAL_PORT: "8080"
volumes:
- .:/opt/qwant/djobi
- ./devops/users/hdfs/.ssh:/home/hdfs/.ssh:ro
spark-worker-proxy:
image: alpine/socat
command: "TCP-LISTEN:80,reuseaddr,fork,su=nobody TCP:spark-master:8081 "
environment:
VIRTUAL_HOST: "spark-worker.*"
VIRTUAL_PORT: "80"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment