NGinx default page redirect to another webpage

i used dietpi as pihole, print-server, scan-server
now i want also use for monitor my energy meter , in germany we have the project
volkszaehler. org with a good software

normally i used it already on another linux box but i want it to merge to my dietpi

i am now stuck in the last step frontend

the project used nginx as a proxy for api , middleware and frontend

website config nginx fo this project

location / {
    proxy_pass http:// 127.0.0.1:8080;
    include /etc/nginx/proxy_params;
  }

  location /middleware {
    rewrite ^/middleware(.php)?(/.*)? $2;
    proxy_pass http:// 127.0.0.1:8080/;
  }

  location /api {
    rewrite ^/api(/.*)? $1;
    proxy_pass http:// 127.0.0.1:8080/;
  }

  location /frontend {
    rewrite ^/frontend/(.*) $1;
    proxy_pass http:// 127.0.0.1:8080/;
  }

if i add this to nginx dietpi default i had double “/” root rediriction → service nginx failed

when i used this above i can not connect anymore to
192.168.2.51/admin for pihole config

where can i add the lines above that both services work together ?

thank you (volkszaehler are under > /var/www/volkszaehler )

second probleme somewhere in the dietpi nginx config there is https redirection the middleware of volkszaehler get a https link not a http .
please can someone tell me where i have to look at ?

ahmm did you followed the guide fully and removed the default setting as described on install docs???

sudo rm /etc/nginx/sites-enabled/default

I hope you did not have done this.

first i have dietpi-backup running .

for my second question i solve it by add more local network to the allowd network in sites-dietpi/dietpi-pihole.conf

i have still the default and edit this files . the probleme ist that i have two root folders
/var/www (direct pihole server)
and
var/www/volkszahler.org

both (pihole and volkszaehler) use / (root of webserver) , pihole run as direct server and volkszaehler as proxy

but how can i configure that both have the correct setting in “default” , my expertice in topic scripting and nginx isnt that deep only on surface. i can code arduino and work with cmd

You need to create an additional VirtHost configuration file where you specify your settings. Simply place the additional file inside /etc/nginx/sites-available/. It should contain the entire server config definition.

do this also work with one as server and one as proxy
or both as server (for volkszaehler there is also a nginx server config possible)

can than both use 192.168.2. 51/ as webserver root -->dietpi-pihole block this with nginx empty site ( normal link to pihole ist 192.168.2.51/admin) → do i have edit dietpi-pihole ?

both config could exist next to each other. Doesn’t matter if they are server or proxy config. Import is following value to distinguish between configurations.

server_name volkszaehler.org;

means this 2nd config is only used for request done against domain volkszaehler.org (or whatever value you set). It’s not reacting on IP address or other domains. There the default config is applicable as this is the default VirtHost.

        listen 80 default_server;
        listen [::]:80 default_server;

To be able to use this VirtHost configuration you would need to set an own DNS name for your volkszaehler.org. This can be done inside PiHole easily by adding a local DNS Record. But I would not recommend using volkszaehler.org as this is the real web site of this project :wink: Better to use an own DNS name like volkszaehler.local.

thank you for this rich information
i used also

i have now 3 files ( default , volkszaehler, pihole)
pihole is a copy of old default

default has
port :: 80 default_server;
and
servername “$hostname”
root /var/www/volkszaehler

volkszahler
port :: 80
and
servername “volkszaehler.local”
root /var/www/volkszaehler

pihole
port :: 80
and
servername “pihole.local”
root /var/www

after some restart and service stop and start its looks like it works now

other problem now
all address above are also at pihole local dns
→ but there are ignored by all other devices (ping , tracert and browser didnt find any address)

→ found the answer CF was the problem

Nginx PiHole configuration file is not needed at all. It’s just a duplicate of the default one. You can leave the default with root at /var/www. Or you remove the volkszaehler configuration. At least it doesn’t make sense to have 3 configuration file just for 2 different root dirs.