Welcome! Log In Create A New Profile

Advanced

LAN-only Reverse proxy with made-up host/domain names

Posted by Baumharz 
LAN-only Reverse proxy with made-up host/domain names
January 13, 2021 09:22AM
I am trying to put nginx in front of a few LAN sites (like pi-hole, munin etc.). My aim is to simply put something like "http://pihole1.lan" in a browser on any device on my LAN, and get to the corresponding page. The reason I want to use nginx in-between is to change some header options (like x-frame) and so that I can always use port 80, no matter what port the actual internal site is running on.

First off, I tried setting up the 'fake' name in my router (OPNsense/Unbound) and alternatively also my pihole (which of course also acts as a DNS), so that pihole1.lan points to the IP address of the machine that is running nginx, which is an Ubuntu 20.04 server.

Then I have this code in my nginx pihole.conf (enabled site):

server {
listen 80;

server_name pihole1.lan;

location / {
proxy_hide_header X-Frame-Options;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-NginX-Proxy true;
proxy_redirect off;

proxy_pass http://192.168.5.3:80/admin/;
}
}

So far so good. Now when I go to http://pihole1.lan, it actually redirects to http://192.168.5.3, which I then see in my browser address bar. But instead of a redirect, I wanted for it to still say "pihole1.lan/admin" in the browser.

Why does it redirect in that way?

Thanks!



Edited 1 time(s). Last edit at 01/13/2021 09:23AM by Baumharz.
Re: LAN-only Reverse proxy with made-up host/domain names
January 17, 2021 09:43AM
For anyone having the same issue, I fixed it by changing from pihole1.lan to pihole1.internal.lan and then having *.internal.lan redirect to my NginX IP address (I did that through an Unbound override in OPNsense).
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 60
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready