<p>It turned out it was only a setting in Traefik. I had to add a second router http rule for the nginx container in my <code>docker-compose.yml</code>:</p>
<pre><code>- &quot;traefik.http.routers.${PROJECT_NAME}_nginx_lan.rule=Host(`192.168.10.100`)&quot;
</code></pre>
<p>So the full nginx section now looks like that:</p>
<pre><code>  nginx:
    image: wodby/nginx:$NGINX_TAG
    container_name: &quot;${PROJECT_NAME}_nginx&quot;
    depends_on:
    - php
    environment:
      NGINX_STATIC_OPEN_FILE_CACHE: &quot;off&quot;
      NGINX_ERROR_LOG_LEVEL: debug
      NGINX_BACKEND_HOST: php
      NGINX_SERVER_ROOT: /var/www/html/web
      NGINX_VHOST_PRESET: $NGINX_VHOST_PRESET
    #      NGINX_DRUPAL_FILE_PROXY_URL: http://example.com
    volumes:
    - ./web:/var/www/html:cached
    labels:
    - &quot;traefik.http.routers.${PROJECT_NAME}_nginx.rule=Host(`${PROJECT_BASE_URL}`)&quot;
    - &quot;traefik.http.routers.${PROJECT_NAME}_nginx_lan.rule=Host(`192.168.10.100`)&quot;
</code></pre>
<p>It works fine. I can now access my Drupal website at <a href="http://192.168.10.100:8000" rel="nofollow noreferrer">http://192.168.10.100:8000</a> from any other device on the same LAN.</p>
<p>In my case, <code>PROJECT_BASE_URL</code> and <code>PROJECT_NAME</code> are configured in an <code>.env</code> file and correspond to <code>drupal.localhost</code> and <code>drupal</code> respectively.</p>

CC BY-SA 4.0
2021-05-10T13:59:34.433Z
2021-05-10T13:59:34.433Z
MrUpsidown
<p>If you are using the docker-compose file from that github repo it's using traefik and should correctly expose port 8000, that should default to 0.0.0.0:8000.
Maybe Ubuntu firewall is blocking incoming TCP port 8000. That could explain why it works on drupal.localhost:8000 which most likely resolves to 127.0.0.1 but not from 192.* LAN.</p>
<p>Check Ubuntu firewall:</p>
<p><code>$ sudo ufw status</code></p>
<p>Make sure incoming TCP 8000 is allowed from anywhere, or at least for your LAN ip range.
If not, you can open it with:</p>
<pre><code>$ sudo ufw allow from any to any port 8000 proto tcp
</code></pre>

CC BY-SA 4.0
2021-05-10T06:33:25.157Z
`sudo ufw status` returns `Status: inactive`.
MrUpsidown
CC BY-SA 4.0
2021-05-10T06:55:05.783Z
I shall also mention that indeed, I am using Traefik with the default ports configuration: `'8000:80'` and that I also get *the same* `404 page not found` when I try to open http://0.0.0.0:8000 or http://localhost:8000 or http://127.0.0.1:8000. I can only reach the website by using the hostname that I have configured in the project (http://drupal.localhost:8000).
MrUpsidown
CC BY-SA 4.0
2021-05-10T11:19:37.150Z
have you tried adding this to your DNS:

```192.168.10.100 Drupal.localhost```

If you don't have a DNS server on your LAN you can add it to the host file on a client you're using. For linux it's ```/etc/hosts``` and windows it's probably ```C:\Windows\System32\drivers\etc\hosts```
wowbagger
CC BY-SA 4.0
2021-05-10T11:21:48.623Z
uhmm... why would I do that? I am not trying to access `Drupal.localhost` from the distant machine, only the IP.
MrUpsidown
CC BY-SA 4.0
2021-05-10T19:50:26.443Z
"Is there any way that I could access the Drupal website directly from the browser on a computer that is on the same LAN (ie. my Windows machine)?" sounded exactly like that but hey, glad it works! Check https://doc.traefik.io/traefik/routing/routers/#rule for more information on Host Headers.
wowbagger
CC BY-SA 4.0
2021-05-09T10:47:06.513Z
2021-05-09T10:47:06.513Z
wowbagger
<p>Here is my setup:</p>
<p>I have a Ubuntu 20.04.2 LTS machine running in VMware (vSphere client).</p>
<p>On this machine, I have a local Drupal website running in Docker using Wodby Docker4Drupal <a href="https://github.com/wodby/docker4drupal" rel="nofollow noreferrer">https://github.com/wodby/docker4drupal</a></p>
<p>The website can be accessed on the Ubuntu machine on <a href="http://drupal.localhost:8000" rel="nofollow noreferrer">http://drupal.localhost:8000</a>.</p>
<p>The Ubuntu machine has an IP of <strong>192.168.10.100</strong> which I can ping from my local Windows machine which is on the same LAN (Windows computer IP address is 192.168.10.97).</p>
<p>Is there any way that I could access the Drupal website directly from the browser on a computer that is on the same LAN (ie. my Windows machine)?</p>
<p>I have tried to access <a href="http://192.168.10.100:8000" rel="nofollow noreferrer">http://192.168.10.100:8000</a> but I get a <code>404 page not found</code> message. On port <code>80</code> I get <code>ERR_CONNECTION_REFUSED</code>. Any idea?</p>
<p>I shall also mention that on the Ubuntu VM, I also get <em>the same</em> <code>404 page not found</code> if I try to reach <a href="http://0.0.0.0:8000" rel="nofollow noreferrer">http://0.0.0.0:8000</a> or <a href="http://127.0.0.1:8000" rel="nofollow noreferrer">http://127.0.0.1:8000</a> or http://localhost:8000. Only the hostname configured within the project resolves to the Drupal website (<a href="http://drupal.localhost:8000" rel="nofollow noreferrer">http://drupal.localhost:8000</a>).</p>
<hr />
<p>Here is the <code>docker-compose.yml</code> I am using.</p>
<pre><code>version: &quot;3.7&quot;

services:
  mariadb:
    image: wodby/mariadb:$MARIADB_TAG
    container_name: &quot;${PROJECT_NAME}_mariadb&quot;
    stop_grace_period: 30s
    environment:
      MYSQL_ROOT_PASSWORD: $DB_ROOT_PASSWORD
      MYSQL_DATABASE: $DB_NAME
      MYSQL_USER: $DB_USER
      MYSQL_PASSWORD: $DB_PASSWORD
    volumes:
      - d4d-db-data:/var/lib/mysql # Use bind mount

  php:
    image: wodby/drupal-php:$PHP_TAG
    container_name: &quot;${PROJECT_NAME}_php&quot;
    environment:
      PHP_SENDMAIL_PATH: /usr/sbin/sendmail -t -i -S mailhog:1025
    volumes:
    - ./web:/var/www/html:cached

  crond:
    image: wodby/drupal-php:$PHP_TAG
    container_name: &quot;${PROJECT_NAME}_crond&quot;
    environment:
      CRONTAB: &quot;0 * * * * drush -r /var/www/html/web cron&quot;
    command: sudo -E LD_PRELOAD=/usr/lib/preloadable_libiconv.so crond -f -d 0
    volumes:
    - ./web:/var/www/html:cached

  nginx:
    image: wodby/nginx:$NGINX_TAG
    container_name: &quot;${PROJECT_NAME}_nginx&quot;
    depends_on:
    - php
    environment:
      NGINX_STATIC_OPEN_FILE_CACHE: &quot;off&quot;
      NGINX_ERROR_LOG_LEVEL: debug
      NGINX_BACKEND_HOST: php
      NGINX_SERVER_ROOT: /var/www/html/web
      NGINX_VHOST_PRESET: $NGINX_VHOST_PRESET
    #      NGINX_DRUPAL_FILE_PROXY_URL: http://example.com
    volumes:
    - ./web:/var/www/html:cached
    labels:
    - &quot;traefik.http.routers.${PROJECT_NAME}_nginx.rule=Host(`${PROJECT_BASE_URL}`)&quot;

  mailhog:
    image: mailhog/mailhog
    container_name: &quot;${PROJECT_NAME}_mailhog&quot;
    labels:
    - &quot;traefik.http.services.${PROJECT_NAME}_mailhog.loadbalancer.server.port=8025&quot;
    - &quot;traefik.http.routers.${PROJECT_NAME}_mailhog.rule=Host(`mailhog.${PROJECT_BASE_URL}`)&quot;

  traefik:
    image: traefik:v2.0
    container_name: &quot;${PROJECT_NAME}_traefik&quot;
    command: --api.insecure=true --providers.docker
    ports:
    - '8000:80'
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock

volumes:
  d4d-db-data:
</code></pre>

<docker><networking><ubuntu><vmware><drupal>
Reaching a Docker environment running in VMware from LAN
MrUpsidown
# Reaching a Docker environment running in VMware from LAN

(Asked by: username_0 on 2021-05-05)

Here is my setup:
I have a Ubuntu 20.04.2 LTS machine running in VMware (vSphere client).
On this machine, I have a local Drupal website running in Docker using Wodby Docker4Drupal https://github.com/wodby/docker4drupal
The website can be accessed on the Ubuntu machine on http://drupal.localhost:8000.
The Ubuntu machine has an IP of 192.168.10.100 which I can ping from my local Windows machine which is on the same LAN (Windows computer IP address is 192.168.10.97).
Is there any way that I could access the Drupal website directly from the browser on a computer that is on the same LAN (ie. my Windows machine)?
I have tried to access http://192.168.10.100:8000 but I get a 404 page not found message. On port 80 I get ERR_CONNECTION_REFUSED. Any idea?
I shall also mention that on the Ubuntu VM, I also get the same 404 page not found if I try to reach http://0.0.0.0:8000 or http://127.0.0.1:8000 or http://localhost:8000. Only the hostname configured within the project resolves to the Drupal website (http://drupal.localhost:8000).

Here is the docker-compose.yml I am using.
version: "3.7"

services:
  mariadb:
    image: wodby/mariadb:$MARIADB_TAG
    container_name: "${PROJECT_NAME}_mariadb"
    stop_grace_period: 30s
    environment:
      MYSQL_ROOT_PASSWORD: $DB_ROOT_PASSWORD
      MYSQL_DATABASE: $DB_NAME
      MYSQL_USER: $DB_USER
      MYSQL_PASSWORD: $DB_PASSWORD
    volumes:
      - d4d-db-data:/var/lib/mysql # Use bind mount

  php:
    image: wodby/drupal-php:$PHP_TAG
    container_name: "${PROJECT_NAME}_php"
    environment:
      PHP_SENDMAIL_PATH: /usr/sbin/sendmail -t -i -S mailhog:1025
    volumes:
    - ./web:/var/www/html:cached

  crond:
    image: wodby/drupal-php:$PHP_TAG
    container_name: "${PROJECT_NAME}_crond"
    environment:
      CRONTAB: "0 * * * * drush -r /var/www/html/web cron"
    command: sudo -E LD_PRELOAD=/usr/lib/preloadable_libiconv.so crond -f -d 0
    volumes:
    - ./web:/var/www/html:cached

  nginx:
    image: wodby/nginx:$NGINX_TAG
    container_name: "${PROJECT_NAME}_nginx"
    depends_on:
    - php
    environment:
      NGINX_STATIC_OPEN_FILE_CACHE: "off"
      NGINX_ERROR_LOG_LEVEL: debug
      NGINX_BACKEND_HOST: php
      NGINX_SERVER_ROOT: /var/www/html/web
      NGINX_VHOST_PRESET: $NGINX_VHOST_PRESET
    #      NGINX_DRUPAL_FILE_PROXY_URL: http://example.com
    volumes:
    - ./web:/var/www/html:cached
    labels:
    - "traefik.http.routers.${PROJECT_NAME}_nginx.rule=Host(`${PROJECT_BASE_URL}`)"

  mailhog:
    image: mailhog/mailhog
    container_name: "${PROJECT_NAME}_mailhog"
    labels:
    - "traefik.http.services.${PROJECT_NAME}_mailhog.loadbalancer.server.port=8025"
    - "traefik.http.routers.${PROJECT_NAME}_mailhog.rule=Host(`mailhog.${PROJECT_BASE_URL}`)"

  traefik:
    image: traefik:v2.0
    container_name: "${PROJECT_NAME}_traefik"
    command: --api.insecure=true --providers.docker
    ports:
    - '8000:80'
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock

volumes:
  d4d-db-data:

**Tags:** docker, networking, ubuntu, vmware, drupal


---

## 2 answers

### Answer by username_0 on 2021-05-10. Score: 0 | Accepted answer

It turned out it was only a setting in Traefik. I had to add a second router http rule for the nginx container in my docker-compose.yml:
- "traefik.http.routers.${PROJECT_NAME}_nginx_lan.rule=Host(`192.168.10.100`)"

So the full nginx section now looks like that:
  nginx:
    image: wodby/nginx:$NGINX_TAG
    container_name: "${PROJECT_NAME}_nginx"
    depends_on:
    - php
    environment:
      NGINX_STATIC_OPEN_FILE_CACHE: "off"
      NGINX_ERROR_LOG_LEVEL: debug
      NGINX_BACKEND_HOST: php
      NGINX_SERVER_ROOT: /var/www/html/web
      NGINX_VHOST_PRESET: $NGINX_VHOST_PRESET
    #      NGINX_DRUPAL_FILE_PROXY_URL: http://example.com
    volumes:
    - ./web:/var/www/html:cached
    labels:
    - "traefik.http.routers.${PROJECT_NAME}_nginx.rule=Host(`${PROJECT_BASE_URL}`)"
    - "traefik.http.routers.${PROJECT_NAME}_nginx_lan.rule=Host(`192.168.10.100`)"

It works fine. I can now access my Drupal website at http://192.168.10.100:8000 from any other device on the same LAN.
In my case, PROJECT_BASE_URL and PROJECT_NAME are configured in an .env file and correspond to drupal.localhost and drupal respectively.


---

### Answer by username_1 on 2021-05-09. Score: 1

If you are using the docker-compose file from that github repo it's using traefik and should correctly expose port 8000, that should default to 0.0.0.0:8000.
Maybe Ubuntu firewall is blocking incoming TCP port 8000. That could explain why it works on drupal.localhost:8000 which most likely resolves to 127.0.0.1 but not from 192.* LAN.
Check Ubuntu firewall:
$ sudo ufw status
Make sure incoming TCP 8000 is allowed from anywhere, or at least for your LAN ip range.
If not, you can open it with:
$ sudo ufw allow from any to any port 8000 proto tcp

> **Comments:**
> **username_0**: `sudo ufw status` returns `Status: inactive`.  
> **username_0**: I shall also mention that indeed, I am using Traefik with the default ports configuration: `'8000:80'` and that I also get *the same* `404 page not found` when I try to open http://0.0.0.0:8000 or http://localhost:8000 or http://127.0.0.1:8000. I can only reach the website by using the hostname that I have configured in the project (http://drupal.localhost:8000).  
> **username_1**: have you tried adding this to your DNS:  ```192.168.10.100 Drupal.localhost```  If you don't have a DNS server on your LAN you can add it to the host file on a client you're using. For linux it's ```/etc/hosts``` and windows it's probably ```C:\Windows\System32\drivers\etc\hosts```  
> **username_0**: uhmm... why would I do that? I am not trying to access `Drupal.localhost` from the distant machine, only the IP.  
> **username_1**: "Is there any way that I could access the Drupal website directly from the browser on a computer that is on the same LAN (ie. my Windows machine)?" sounded exactly like that but hey, glad it works! Check https://doc.traefik.io/traefik/routing/routers/#rule for more information on Host Headers.  

---

