Need help with NGINX URL Rewriting

Started by Layer8, July 05, 2023, 03:18:31 PM

Previous topic - Next topic
Hello all,

I am a newbe in loadbalancing.

I would like to use NGINX on OPNsense for the following concept and not sure what to configure and how to write which rule exactly for this scenario.

We have a Domain like remote.domain.com and we would like to make different types of webbased remote services available over this domain for different projects (aka customers). The scheme of the URL to access the services should look like this:

remote.domain.com/selfservice/001
remote.domain.com/remoteaccess/004
remote.domain.com/statistics/43563

selfservice, remoteaccess and statistics are three different types of services.

001 = titan, 004, = bigtech, 43563 = hiddenchamp is the ID of the customers. But it should also be possible to use the project-/customer-name instead of the ID, like: remote.domain.com/selfservice/004 will use the same upstream like remote.domain.com/selfservice/bigtech

For each type of service+customer, we have a separated upstream, which can be a group of one ore more docker containers as upstream servers. Each container is directly connected to the physical network with its own IP.

What we have configured so far:
- We have a http server for remote.domain.com
- We have a location for remoteaccess, which is currently configured with pattern "/"
- We have differend upstreams, one for earch service and customer type, like "project 004 remoteaccess"
- In each Upstream, we have one or more upstream servers. For remoteaccess, these Upstream servers are available over ip or dns, like: http://10.10.4.20/rmtservice

At the moment, we can access remote.domain.com/rmtservice , because we hat the "/" pattern set.

I think, we need a custom location for each URL path, right?

I also think, that we need a URL rewriting rule to access the upstream "project 004 remoteaccess" when we try to open remote.domain.com/remoteaccess/004 in the browser, which will lead to x.x.x.x/rmtservice.

How to write this rule? I already tried to understand the syntax but all I tried did not work.

And is there anything else to configure or am I completely wrong?

Thanks.

Just found out that URL Path Prefix in a location is the key. This adds the URL path to the upstream server in the nginx.conf.

But its not working. Looks like we have a bug here. I will open a new topic in the 23.1 production series forum.