0

I am trying to figure out why when I access my local IP (192.168.x.x) from another PC does not redirect to localhost of my PC.

My configuration is this:

I have a hypervisor on my server. On the hypervisor I have a VM with Ubuntu Server 18. In Ubuntu I have installed a Docker container with ERPNext app. The app is available at http://localhost on host VM, but when I want to access the local IP of VM (from another machine) I got a 404 page not found. If the containers are down I got an error page: this site can't be reached.

For more informations, I also post this question on ERPNext Discuss Forum.

1 Answers1

0

It seems someone from ERPNext already answered this question on ERPNext Discuss Forum. I'm going to copy the solution here for future reference.

  1. Add following labels to erpnext-nginx service
      - "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"

to get the following configuration of the service:

  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
  1. Copy env-local to .env and change mysite.localhost to erpnext-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

  1. Add a file sites/currentsite.txt e.g. execute in container
echo erpnext-nginx > currentsite.txt

refer here

  • 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
Konrad Botor
  • 141
  • 4