Quantcast
Channel: Nginx Forum - How to...
Viewing all articles
Browse latest Browse all 4759

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

$
0
0
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!

Viewing all articles
Browse latest Browse all 4759

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>