How to handle requests from the same domain but with different paths and ports?

Good afternoon,

I have the following scenario:

tst-agro.mydomain.com.br/agro
tst-agro.mydomain.com.br/ti
tst-agro.mydomain.com.br/nfe

Each app has its own unique port and when the user accesses it I apply the regex below. middlewares:
rewrite-agro:
replacePathRegex:
regex: "^/agro/(.*)"
replacement: "/webapp/$1"

after the regex: tst-agro.mydomain.com.br/webapp/

The problem is that some requests are coming through another route

tst-agro.mydomain.com.br/app-root/protheuslib-tface_env_tst_ti/

Since it is a third-party program, I have no way of knowing how many of these routes would be needed to create a rule for each one, and it could also be for the company if any of them were not mapped.

Does anyone have any idea how to handle this? I didn't want to make a "subdomain" ti.tst-agro.mydomain.com.br, because I think it would be worse for the users.

GUI web apps usually expect to be root (/), therefore a sub-domain is best practice.

Not sure if I understand your use-case correctly, but wouldn’t this work, still only re-writing /agro:

.rule=Host(`tst-agro.mydomain.com.br`) && ( PathPrefix(`/agro`) || PathPrefix(`/app-root `) )

Good morning

I have this scenario: I have several different environments (agro, it, hr, nfe, proprod), the default environment would be "Agro", but some sectors like HR will access another environment (hr).

By default, to access the app, a request is made at the address:
localhost:appPort/webapp

To simplify things for the user, the idea was to have different paths (/agro, /nfe, /rh) and remove them with regex to send the correct request to the backend.

But when I tested, I saw that there is another route at the same level as /webapp, which is /app-root. If I access it via IP, the app itself already handles it, but since the idea is to use the reverse proxy for security reasons, from what I read I would have to handle it, right?

When I access:
https://tst-protheus.mydomain.ind.br/agro
looking through the browser's dev tools, a request is also sent to the url (which would return index.html, but gives a 404 error).
https://tst-protheus.mydomain.ind.br/app-root

If I create a rule for the default url (tst-protheus.mydomain.ind.br) and in the services point to the root url (https://localhost:appPort) it "works", but not correctly since everything would go through a single port. Example:

default-agro:
rule: "Host(tst-protheus.mydomain.ind.br) "
entryPoints: [websecure]
service: agro-service
tls: true

services:
agro-service:
loadBalancer:
serversTransport: agro
servers:

  • url: "localhost:5000"

Is there any way to correctly handle these requests that come from the /app-root route or would I have to change to subdomains?

note: sorry for the links, the site only limits it to 4 links.

I assume you are talking about a web app, not API. Then usually the PathPrefix() and stripPrefix method does not work. The initial page may load, but all links, images and other dependencies (like /static/script.js) will have the wrong path. Go with sub-domains.