We are trying to run multiple instances of SS using docker. We were able to run these instances on different ports:
website.com:8000
website.com:7000
How can we change that to survey1.website.com or website.com/survey1 and so on?
We used the yml file from here and simply changed the port numbers from ports and baseurl lines.
alfeg
(Victor Gladkikh)
January 22, 2021, 4:50pm
#3
Hi, @ashwinikalantri
Basically You need a reverse proxy to run and route request before those docker images.
For a sample please take a look at this repo: https://github.com/surveysolutions/docker-compose/tree/multiplehq
In this sample repo I use Traefik to handle all incoming request at port 80:
traefik:
image: traefik:v2.4
command:
- "--providers.docker=true"
- "--providers.docker.exposedbydefault=false"
- "--entrypoints.web.address=:80"
volumes:
- "/var/run/docker.sock:/var/run/docker.sock:ro"
restart: always
ports:
- "80:80"
Then I configure HQ services using using docker labels for Traefik like this:
hq1:
image: surveysolutions/surveysolutions
depends_on:
- "db"
environment:
HQ_ConnectionStrings__DefaultConnection: Server=db;Port=5432;User Id=postgres;Password=pg_password;Database=hq1
HQ_Headquarters__BaseUrl: http://${HQ1_HOST}
volumes:
- ./data/app1:/app/AppData
restart: always
labels:
- "traefik.enable=true"
- "traefik.http.routers.hq1.rule=Host(`${HQ1_HOST}`)"
hq2:
image: surveysolutions/surveysolutions
depends_on:
- "db"
environment:
HQ_ConnectionStrings__DefaultConnection: Server=db;Port=5432;User Id=postgres;Password=pg_password;Database=hq2
HQ_Headquarters__BaseUrl: http://${HQ2_HOST}
volumes:
- ./data/app2:/app/AppData
restart: always
labels:
- "traefik.enable=true"
- "traefik.http.routers.hq2.rule=Host(`${HQ2_HOST}`)"
Full Docker Compose Yaml configuration can be found here: https://github.com/surveysolutions/docker-compose/blob/multiplehq/docker-compose.yml
HQ1_HOST
and HQ2_HOST
just are predefined in /.env
file in root of repository to hq1.lvh.me
and hq2.lvh.me
( *.lvh.me
domains are always resolved to 127.0.0.1
)
If You clone/fork this repo at branch multiplehq
and run docker-compose up
, then after a while HQ should be available at predefined addresses:
Thank you all for the possible solutions. But with the release of Workspaces in 21.01, this implementation has been rendered moot! This will be tremendous helpful for us.
2 Likes