OPNsense Forum

English Forums => Web Proxy Filtering and Caching => Topic started by: Crappysauce on August 07, 2021, 12:49:04 am

Title: NGINX Reverse Proxy using subdomains only?
Post by: Crappysauce on August 07, 2021, 12:49:04 am
Hi, I have a bunch of subdomains that I wish to redirect to their respective LAN servers using NGINX.

I set the HTTP servers according to the post here: https://forum.opnsense.org/index.php?topic=19305.0 (https://forum.opnsense.org/index.php?topic=19305.0)

Everything seems to be find except if I enter my domain (eg. domain.com) instead of the subdomain (eg. subdomain1.domain.com), it uses the the first location that I have created.

Question is, how do I set it so that it only directs the subdomain traffic and ignore all requests to my domain?
Title: Re: NGINX Reverse Proxy using subdomains only?
Post by: fabian on August 07, 2021, 12:25:01 pm
Nginx and any other Webserver has to respond somehow to a request it gets.

The nginx developers decided that if you they don't have a matching server, they use the first or the default server. Since you cannot mark a server as a default, you will get the first one. If you don't want it to respond with that on the main domain, you can define it with an empty server that always responds with a default page or 404.
Title: Re: NGINX Reverse Proxy using subdomains only?
Post by: Crappysauce on August 09, 2021, 11:36:49 pm
Thanks fabian.

I'll play around with it, otherwise I might just go back to HAProxy for it's simplicity. Hoping I don't have to since Nginx allows for more(?) security with the WAF.

Then again, I'm still a total noob trying to learn all that I can on my own.  ::)