Nginx returning 404, can't figure out why

hi community,
I’m facing issues with a fresh dietpi installation (using an older version on some mini pc for years already without issues, thanks a bunch for the incredible project).

tl;dr
getting 404 all the time when trying to access nginx over local network.

network connection is stable, using SSH without issues, also gitea is reachable via port 3000.

however, accessing the other installations (nextcloud, pihole) on port 80/443 does not work.

I can access nginx only from the dietpi instance via localhost:

curl http://localhost
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
    body {
        width: 35em;
        margin: 0 auto;
        font-family: Tahoma, Verdana, Arial, sans-serif;
    }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>

<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>

<p><em>Thank you for using nginx.</em></p>
</body>
</html>

but using 127.0.0.1 or the actual network ip always returns this (from the machine itself or any other machine within the local network)

curl http://192.168.1.10
404 page not found

installed software:

  • nextcloud
  • gitea
  • k3s
  • LEMP
  • samba server
  • nfs server
  • certbot

what’s really weird is that if I stop nginx I still get 404 responses

dietpi-services stop nginx

 DietPi-Services
─────────────────────────────────────────────────────
 Mode: stop nginx

[  OK  ] DietPi-Services | stop : nginx
root@himbeere2:~# curl http://localhost
404 page not found
root@himbeere2:~# curl http://192.168.1.10
404 page not found

dietpi block public is off:

dietpi-pihole-block_public_admin.off

no other service is listening on port 80:

netstat -ltnp | grep -w ':80'

… returns no results.

same results from the browser BTW

any ideas what I’m missing here?

Required Information

  • DietPi version:
G_DIETPI_VERSION_CORE=8
G_DIETPI_VERSION_SUB=12
G_DIETPI_VERSION_RC=1
G_GITBRANCH='master'
G_GITOWNER='MichaIng'
G_LIVE_PATCH_STATUS[0]='applied'
  • Distro version: bullseye
  • Kernel version: Linux himbeere2 5.10.0-20-amd64 #1 SMP Debian 5.10.158-2 (2022-12-13) x86_64 GNU/Linux
  • SBC model: Native PC (x86_64)
  • Power supply used: 230V, Mac mini
  • SD card used: harddisk

looks like nothing is listening on port 80.
what about https:// ?
And can you show journalctl -u nginx.

can you share following pls

ss -tulpn | grep LISTEN

Thanks for the replies here. I’m not at home currently, but will answer when I’m back. Merry Christmas!

Take your time and I enjoy the time with your loved ones

Ok. So I went for a complete re-install of dietpi (there wasn’t a lot there yet anyways) and it all works. Until I install k3s. I assume nginx is somehow reverse-proxying to k3s, but I couldn’t identify how this is setup yet. Unfortunately the docs are not of much help here either.

found an explanation why nginx wasn’t responding to my requests (when k3s was installed, too), see k3s and nginx conflicts on port 80 for IPv4 Β· Issue #2403 Β· k3s-io/k3s Β· GitHub

I’ve managed to change the ports used by traefik by k3s as described here: k3s and nginx conflicts on port 80 for IPv4 Β· Issue #2403 Β· k3s-io/k3s Β· GitHub

maybe it would be helpful to mention this in the README within dietpi software? i.e. that you cannot easily run locally hosted software packages when you also want to run k3s, out of the box.

Well it depends what kind of software you are trying to run on K3S. Following your post you tried running traefik?

From what I’ve learned traefik is installed by default along with k3s and takes over port 80/443 on the host. The reason this wasn’t visible to me was that it sets up iptables routes to forward incoming traffic.

while

ss -tulpn | grep LISTEN

still lists nginx.

ok I wasn’t aware on this behavior.

Means, we would need to adjust our installation process to avoid further conflicts with our web server implementation @MichaIng

What I see, we have 3 options

Simplest solution might option #1 to have it just disabled

nano /etc/systemd/system/k3s.service.d/dietpi.conf

adjust the service definition file as follow

[Service]
Restart=on-success
ExecStart=
ExecStart=/usr/local/bin/k3s \
    server \
    --disable traefik

reload and restart service

systemctl daemon-reload
systemctl restart k3s.service
1 Like