Armin
December 15, 2021, 12:13am
1
Dear erpnext-community,
I recently moved my erpnext from a bench setup to a docker setup.
In the old bench setup, I used multi-tenancy to point different domains to different sites.
I even used multiple domains for one site (e.g. example.com and www.example.com pointed at the same site).
Unfortunately, I am unable to point multiple domains to this one site in docker setup (now just www.example.com points to the site, but not example.com ).
During docker installation I used following Environment Variables:
LETSENCRYPT_EMAIL=office@example.com
ERPNEXT_VERSION=v13.16.1
FRAPPE_VERSION=v13.16.0
MARIADB_HOST=mariadb
MYSQL_ROOT_PASSWORD=somesupersecurepassword
SITE_NAME=www.example.com
SITES=`www.example.com`
DB_ROOT_USER=root
ADMIN_PASSWORD=supersecuretoo
INSTALL_APPS=erpnext
ENTRYPOINT_LABEL=traefik.http.routers.erpnext-nginx.entrypoints=websecure
CERT_RESOLVER_LABEL=traefik.http.routers.erpnext-nginx.tls.certresolver=myresolver
HTTPS_REDIRECT_RULE_LABEL=traefik.http.routers.http-catchall.rule=hostregexp(`{host:.+}`)
HTTPS_REDIRECT_ENTRYPOINT_LABEL=traefik.http.routers.http-catchall.entrypoints=web
HTTPS_REDIRECT_MIDDLEWARE_LABEL=traefik.http.routers.http-catchall.middlewares=redirect-to-https
HTTPS_USE_REDIRECT_MIDDLEWARE_LABEL=traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https
SKIP_NGINX_TEMPLATE_GENERATION=0
WORKER_CLASS=gthread
Since I am not really familiar with docker at this point, I would be very grateful for some tips.
To sum it up:
How to point multiple domains (example.com and www.example.com ) to my site (www.example.com ) in docker setup?
Thank you very much for your time.
Best regards,
AH
Armin
December 15, 2021, 12:27am
3
Thank you for your quick response
I will try the instructions and will share my experience for others later.
Best regards,
AH
Armin
December 19, 2021, 5:30pm
4
So, I tried it myself now for some time and I am facing issues (due to my lack of skill ).
I edited the file docker-compose.yml in directory frappe-docker as follows:
(Name of docker project is erpnext, name of frappe site is www.example.com )
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
- SKIP_NGINX_TEMPLATE_GENERATION=${SKIP_NGINX_TEMPLATE_GENERATION}
labels:
- "traefik.enable=true"
- "traefik.http.routers.erpnext-nginx.rule=Host(${SITES})"
# edit starts here
- "traefik.http.routers.custom-domain.rule=Host(`example.com`)"
- "traefik.http.routers.custom-domain.entrypoints=web"
- "traefik.http.middlewares.custom-domain.headers.customrequestheaders.Host=www.example.com"
- "traefik.http.routers.custom-domain.middlewares=custom-domain"
- "traefik.http.routers.custom-domain.tls.certresolver=myresolver"
# edit ends here
- "${ENTRYPOINT_LABEL}"
- "${CERT_RESOLVER_LABEL}"
- "traefik.http.services.erpnext-nginx.loadbalancer.server.port=8080"
After I restarted the docker container I expected that entering example.com in a browser would redirect me to www.example.com and the corresponding frappe site.
Unfortunately, that did not happen. I only get “404 page not found”.
Can anyone help me to fix this problem?
Best regards,
AH
Armin
December 19, 2021, 5:47pm
5
Hello everyone, I managed to solve it!
I had to comment out the part, where the entrypoints are set (since traefik already had default entrypoint set).
So my docker-compose.yml file looks like this now:
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
- SKIP_NGINX_TEMPLATE_GENERATION=${SKIP_NGINX_TEMPLATE_GENERATION}
labels:
- "traefik.enable=true"
- "traefik.http.routers.erpnext-nginx.rule=Host(${SITES})"
# edit starts here
- "traefik.http.routers.custom-domain.rule=Host(`example.com`)"
#- "traefik.http.routers.custom-domain.entrypoints=web"
- "traefik.http.middlewares.custom-domain.headers.customrequestheaders.Host=www.example.com"
- "traefik.http.routers.custom-domain.middlewares=custom-domain"
- "traefik.http.routers.custom-domain.tls.certresolver=myresolver"
# edit ends here
- "${ENTRYPOINT_LABEL}"
- "${CERT_RESOLVER_LABEL}"
- "traefik.http.services.erpnext-nginx.loadbalancer.server.port=8080"
Maybe it can help someone else too
Thank you and best regards,
AH
1 Like