Try these steps.
- Add following labels to
erpnext-nginxservice
- "traefik.http.routers.erpnext-nginx.rule=HostRegexp(`{catchall:.*}`)"
- "traefik.http.middlewares.erpnext-nginx.headers.customrequestheaders.Host=erpnext-nginx"
- "traefik.http.routers.erpnext-nginx.middlewares=erpnext-nginx"
erpnext-nginx:
image: frappe/erpnext-nginx:${ERPNEXT_VERSION}
restart: on-failure
environment:
- FRAPPE_PY=erpnext-python
- FRAPPE_PY_PORT=8000
- FRAPPE_SOCKETIO=frappe-socketio
- SOCKETIO_PORT=9000
labels:
- "traefik.enable=true"
- "traefik.http.routers.erpnext-nginx.rule=Host(${SITES})"
- "${ENTRYPOINT_LABEL}"
- "${CERT_RESOLVER_LABEL}"
- "traefik.http.services.erpnext-nginx.loadbalancer.server.port=80"
- "traefik.http.routers.erpnext-nginx.rule=HostRegexp(`{catchall:.*}`)"
- "traefik.http.middlewares.erpnext-nginx.headers.customrequestheaders.Host=erpnext-nginx"
- "traefik.http.routers.erpnext-nginx.middlewares=erpnext-nginx"
volumes:
- sites-vol:/var/www/html/sites:rw
- assets-vol:/assets:rw
- copy env-local to .env and change
mysite.localhosttoerpnext-nginx
cp env-local .env
# change mysite.localhost to erpnext-nginx
sed -i -e "s/mysite.localhost/erpnext-nginx/g" .env
NOTE: recommended to use exact versions like (frappe v12.9.1 and erpnext v12.11.2) instead of edge or v12 tag
- add a file
sites/currentsite.txte.g. execute in containerecho erpnext-nginx > currentsite.txt, refer frappe_docker/site-operations.md at main · frappe/frappe_docker · GitHub
- This configuration sets default site for the deployment.
- traefik labels: these tell all the incoming requests to be reverse proxied to erpnext-nginx container and also sets the Host header to erpnext-nginx.
- erpnext-nginx container gets host header as erpnext-nginx irrespective of any site input in request and serves the site mentioned in currentsite.txt, erpnext-nginx