Local domain cannot be used with NGINX (Docker/Container)

Have some feedback, questions, suggestions, or just fancy a chat? Pop it in here.
wmcig
Posts: 16
Joined: Wed Aug 25, 2021 12:17 pm

Local domain cannot be used with NGINX (Docker/Container)

Post by wmcig »

Hello,

I am new to DietPi. I have Docker and Docker-compose installed and running. I already have PiHole running successfully as a container.

Now I wanted to get NGINX running as a web server in a container. That has also worked so far. But there is one thing I just can't get right.

When I continue this tutorial (https://marcit.eu/en/2021/04/28/dockeri ... ginx-php8/) and want to activate a local domain, I fail at the specification in the hosts file in the "etc" directory.

I have tried various IP entries to activate and use the local domain.

Here is my hosts file:

Code: Select all

127.0.0.1 localhost
127.0.1.1 DietPi
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
192.168.178.1 fritz.box
192.168.178.42 phpfpm.local
The last line is the entry for the local domain. It is the IP of the Raspberry Pi in the local network. But changing the IP to "127.0.0.1" did not help either.

Following the entrys in my resolv.conf file:

Code: Select all

  GNU nano 5.4                       resolv.conf                                
nameserver 1.1.1.1
nameserver 1.0.0.1
I cannot access the NGINX page via the local domain.

What do I have to specify where so that I can use the local domain and point it to the Docker environment ?
Is it possibly due to PiHole or the container network?

I would be very pleased to receive help!
User avatar
Joulinar
Posts: 6001
Joined: Sat Nov 16, 2019 12:49 am

Re: Local domain cannot be used with NGINX (Docker/Container)

Post by Joulinar »

Hi,

I guess your clients use PiHole? Correct? If yes, you need to add your local domain into PiHole as PiHole is doing your DNS resolution inside your network.
  1. login to PiHole
  2. Local DNS
  3. DNS records
  4. add your domain phpfpm.local and IP 192.168.178.42
  5. ADD
Maybe you need to restart the container.

But why you have installed PiHole and Nginx inside docker? This all could have been done without Docker using dietpi-software catalogue and you cold have saved system resources as there would be no Docker overhead.
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
wmcig
Posts: 16
Joined: Wed Aug 25, 2021 12:17 pm

Re: Local domain cannot be used with NGINX (Docker/Container)

Post by wmcig »

Joulinar wrote: Thu Oct 07, 2021 9:02 pm Hi,

I guess your clients use PiHole? Correct? If yes, you need to add your local domain into PiHole as PiHole is doing your DNS resolution inside your network.
  1. login to PiHole
  2. Local DNS
  3. DNS records
  4. add your domain phpfpm.local and IP 192.168.178.42
  5. ADD
Maybe you need to restart the container.

But why you have installed PiHole and Nginx inside docker? This all could have been done without Docker using dietpi-software catalogue and you cold have saved system resources as there would be no Docker overhead.
I tried it but it is not working.

Why I installed these inside docker? I thought, if I install PiHole via the software catalogue, I could not use any other software anymore. So I could use Pihole and Nginx and other software on ONE Raspberry Pi with your software catalogue?
User avatar
Joulinar
Posts: 6001
Joined: Sat Nov 16, 2019 12:49 am

Re: Local domain cannot be used with NGINX (Docker/Container)

Post by Joulinar »

So I could use Pihole and Nginx and other software on ONE Raspberry Pi with your software catalogue?
That's the basic idea of DietPi to have majority of software title working together. You just need to select Nginx as web server preference and PiHole will be installed using Nginx automatically.

Code: Select all

Webserver Preference : [Nginx]
On Docker do you forward port 80 to your your PiHole container or to the Nginx container?
On your clients you could check DNS resolution by running nslookup phpfpm.local (on Windows) to check what IP address will be returned.
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
wmcig
Posts: 16
Joined: Wed Aug 25, 2021 12:17 pm

Re: Local domain cannot be used with NGINX (Docker/Container)

Post by wmcig »

Code: Select all

nslookup phpfpm.local
Server:         1.1.1.1
Address:        1.1.1.1#53

** server can't find phpfpm.local: NXDOMAIN
User avatar
Joulinar
Posts: 6001
Joined: Sat Nov 16, 2019 12:49 am

Re: Local domain cannot be used with NGINX (Docker/Container)

Post by Joulinar »

On which client did you executed this because this client is not using PiHole for DNS resolution. Or did you executed this on DietPi?
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
wmcig
Posts: 16
Joined: Wed Aug 25, 2021 12:17 pm

Re: Local domain cannot be used with NGINX (Docker/Container)

Post by wmcig »

Joulinar wrote: Fri Oct 08, 2021 7:54 am On which client did you executed this because this client is not using PiHole for DNS resolution. Or did you executed this on DietPi?
I executed it on DietPi!
User avatar
Joulinar
Posts: 6001
Joined: Sat Nov 16, 2019 12:49 am

Re: Local domain cannot be used with NGINX (Docker/Container)

Post by Joulinar »

This test to be done on a different client like a desktop computer. At least on the client you try to open that domain.
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
wmcig
Posts: 16
Joined: Wed Aug 25, 2021 12:17 pm

Re: Local domain cannot be used with NGINX (Docker/Container)

Post by wmcig »

Joulinar wrote: Fri Oct 08, 2021 10:25 am This test to be done on a different client like a desktop computer. At least on the client you try to open that domain.
Okay, now I am using my Linux Laptop-Terminal to use nslookup. The following code-output was created:

Code: Select all

nslookup phpfpm.local
Server:    192.168.178.42
Address:  192.168.178.42#53

Name:    phpfpm.local
Address: 192.168.178.42
When I am using the IP number and the Portnumber of the NGINX server (8080), I can see the "hello world" text.

But the local domain I can not using.
User avatar
Joulinar
Posts: 6001
Joined: Sat Nov 16, 2019 12:49 am

Re: Local domain cannot be used with NGINX (Docker/Container)

Post by Joulinar »

I guess you need to use phpfpm.local:8080
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
Post Reply