Reverse Proxy: One vHost with locations for different docker apps reddit / selfhosted ---------------------------------------------------------------------- tighthead_lock · 2023-11-30 12:52 My idea was to create one vHost myserver.local and have custom locations pointing to different docker apps: myserver.local directly points to the NPM admin GUI on port 81. myserver.local/portainer should point to portainer:8000 I tried it with NPM but it doesn't seem work: I get to the admin GUI but only get a 404 for /portainer... Googling the issue I mostly read about using sub domains instead of locations, but at the moment I am limited to one DNS entry for my home server. Any suggestions? ---------------------------------------------------------------------- WantDollarsPlease · 2023-11-30 13:11 Subdomains are better because some applications don't like to be in a custom path and might not work. A single DNS entry (like \*.local.example.com) should be enough to use anything in the subdomain instead of creating one entry for each application. ([portainer.local.example.com](https://portainer.local.example.com), [pihole.local.example.com](https://pihole.local.example.com), etc). If your provider doesn't support that, can't you use Cloudflare? It's free. ---------------------------------------------------------------------- WantDollarsPlease · 2023-11-30 13:15 If you insist in the path routing, portainer supports a parameter to set the base parameter. You can read more [here](https://docs.portainer.io/advanced/cli) (Look for --base-url) ---------------------------------------------------------------------- Nintenuendo_ · 2023-11-30 14:09 Yeah don't do it like this! Buy a domain, use cloudflare DNS nameservers, and just use nginx or something as your web server and reverse proxy, and subdomain your services in the proxy-confs folder. This is how someone would set it up professionally, and if it's your first time you'll learn a lot of super useful skills for the future. I do this for [my services](https://nintenuendo.tv), it's fantastic. ---------------------------------------------------------------------- Simplixt · 2023-11-30 15:34 Better find a solution for your "just one DNS entry" problem, it's not worth the effort getting all your apps running via path ---------------------------------------------------------------------- Still-Snow-3743 · 2023-11-30 16:46 Usually applications are written like this: if (request.path == '/admin') { do\_admin\_panel\_things(); } else if (request.path == '/dasboard') { do\_dashboard\_stuff(); } The trouble is that if you are setting things up the way you propose, then those commands will never work in the code for the applications that are running. The only real solution is to use subdomains. ---------------------------------------------------------------------- watchdog_timer · 2023-11-30 20:24 I could be mistaken, but I believe [Cloudflare doesn't allow second- level subdomains](https://developers.cloudflare.com/ssl/troubleshootin g/version-cipher-mismatch/#multi-level-subdomains) on their free plan ---------------------------------------------------------------------- WantDollarsPlease · 2023-11-30 20:31 That's only for the universal certificate (I have no idea what that is lol), but regular record creation does work normally and nginx proxy manager handles the certificates for me 😅 ---------------------------------------------------------------------- watchdog_timer · 2023-12-01 19:47 Do you have Cloudflare set up to proxy your requests, so it can filter out DDOS etc? If so, I don't understand how it can work. The Universal SSL is the certificate Cloudflare uses between their proxy and your site's visitors. As mentioned in my link above, it only supports your server's TLD and a wildcard single-level subdomain. I think NPM is able to create certificates for you because it's only checking DNS entries. Traffic between your client and Cloudflare, if proxied through Cloudflare, is using Cloudflare's Universal SSL certificate, not your NPM-generated ones. Could you more fully describe your set-up? I'm genuinely curious, because I want to use second-level subdomains with a Cloudflare tunnel. All the posts I've read in the Cloudflare forums say that's not possible without a paid plan. ---------------------------------------------------------------------- WantDollarsPlease · 2023-12-02 01:13 You're probably right. I have a *.local.mydomain.com that I use for local addresses (like 192.168.1.5) and I also configured my VPN to work on that too. So in this case I have proxy disabled because it makes no sense in this case. All internet-facing stuff (including what's behind Cloudflare proxy) is in the first-level domain so I never had trouble with it. ---------------------------------------------------------------------- tighthead_lock · 2023-12-02 08:02 It's all local and my router is tricky when it comes to DNS. I ended up ordering a Raspberry Pi to act as a local DNS server, as I want to be able to shut my apps server down without impacting network services. ---------------------------------------------------------------------- tighthead_lock · 2023-12-02 08:04 Yeah, but other apps will not have this feature. I used to work with a WAF that supported path translation in both ways, but this would be an even bigger overkill than setting up a local DNS server :D ---------------------------------------------------------------------- tighthead_lock · 2023-12-02 08:04 Thanks, that's my plan now. The Raspberry Pi will be delivered today. ---------------------------------------------------------------------- tighthead_lock · 2023-12-02 08:05 Yeah, you would need path translation, but that's way too much effort. ---------------------------------------------------------------------- WantDollarsPlease · 2023-12-02 10:38 You can still use cloudflare for a local IP (I do) When I type portainer.local.mydomain.tld it resolves to my local IP (192.168.1.2) so it only works on my local network. If you use a local DNS you won't be able to have ssl certificates.