NGINX Reverse Proxy using subdomains only?

Started by Crappysauce, August 07, 2021, 12:49:04 AM

Previous topic - Next topic
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

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?

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.

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.  ::)