English Forums > Web Proxy Filtering and Caching

[SOLVED] Nginx and Omada controller (Solved for now)

(1/2) > >>

mm23282236:
I'm trying to get Nginx to reverse proxy the Omada controller.

Basically when you set it up in the Nginx GUI and try to accees the Omada host you are greeted with a blank page, a 404 page, or a time out.

After much troubleshooting I finally narrowed it down to a couple of lines in the nginx.conf file.

- "proxy_set_header Host $host;"
- "proxy_pass https://upstream<UUID>;"

If I comment out the host header and set proxy_pass to the actual host of the machine Omada is hosted at, it works flawlessly. The downside to all of this, as soon as you make any changes in the gui the config is wiped out and we are back to square 1.

So a few questions:

- Is there a way to create a custom configuration for this one host and still be able to use the GUI for other settings?

- Is there away to disable the host header and/or use proxy_pass with a single server instead of trying to load balance with upstream?

- Is there something im overlooking?

Fright:

--- Quote ---Is there a way to create a custom configuration for this one host and still be able to use the GUI for other settings?
--- End quote ---
yes.
at the end of each server block there is a hook like

--- Code: ---    include 728012f5-11ee-4fe3-ac61-7d8fb92420ad_post/*.conf;

}
server {

--- End code ---
so you can create uuid_post dir at /usr/local/etc/nginx and place a .conf file with additional settings in this folder. in this case it will be full locations blocks for Omada


--- Quote ---Is there away to disable the host header?
--- End quote ---
afaik host header can not be disabled. it may not be present in the configuration. but then nginx will set the "$proxy_host" value for it. which in combination with the use of "upstreams" in proxy_pass will give an undesirable result.


--- Quote ---and/or use proxy_pass with a single server instead of trying to load balance with upstream?
--- End quote ---
not via gui.

mm23282236:
Awesome, that worked! Thanks Fright.

For those coming here looking for answers here are the steps that I took. I created a location to be used as a "template" then deleted it afterwards, you'll see this in the steps below. This will require dealing with command line stuff, so if you are not comfortable with that, don't do this. Also, this assumes you already have somewhat of a grasp dealing with Nginx configs. I am not great at explaining things, so if others have a better and/or prettier way to do this, please feel free to do so.


* Within the OPNsense Nginx GUI, remove anything you have done dealing with Omada.
* Create a temporary "template" location. Click the HTTP(s) drop down, select location, and create a location for Omada. We will delete this later.
* Click the HTTP(S) drop down and choose HTTP Server Add a server with the correct settings and hostname(s). Make sure to include your temporary template here.
* Go back to the General Settings tab and apply the changes.
* Get to the command line of your server and edit the nginx.conf file. This is currently located in /usr/local/etc/nginx/nginx.conf
* Find the "server { }" section that deals with Omada. Once that line is found, copy the entire "location / { }" block to a notepad for later reference.
* At the bottom of the server block you should see an include line with a UUID. Something like "include <UUID>_post/*.conf;" Make note of that UUID string. ** Note, there are multiple UUID strings here. Make sure you get the UUID listed in the server block and not the location block.
* Exit your editor.
* In the /usr/local/etc/nginx/ directory, create a directory matching the UUID you just found.
* Create a file named <whatever>.conf, making sure it ends in ".conf". I used "slash.conf" for mine. In this file paste the location block you copied from the previous step into it.
* Look for a line that says "proxy_set_header Host $host;" and remove that line
* If you see a line that says "proxy_pass https://upstream<UUID>;" Remove that line as well.
* Below the line that says "proxy_buffering off;" (really anywhere within the location block itself) create a new line that says "proxy_pass https://<IP_or_hostname_of_Omada>:8043"
* Save and exit your editor.
* Go back to the OPNsense Nginx GUI and remove the temporary location from earlier. After you apply the settings, the service should restart and your custom config should be retained.
If everything went well, you should now be able to access the Omada interface through your proxy.

I'm unsure if this setup will survive an update, I'm guessing it wont, so make note of what you did to get it to work so that when you update its a somewhat quick process. Hopefully in the future there will be some more options in the GUI to better customize Nginx for services that don't like to play nice.....Omada!....

Thanks and I hope this helps. Good luck!

Fright:
glad it works  ;)

--- Quote ---I'm unsure if this setup will survive an update, I'm guessing it wont
--- End quote ---
will survive

tozim:
Just to be clear, this completely bypasses the upstream config done in the OPNsense GUI, right?

Navigation

[0] Message Index

[#] Next page

Go to full version