0

I want to do this

location ~ /.*$ {
    proxy_pass http://mysecondapp.local;
}

but only if the user is in /mysecondapp or in /mysecondapp/something and not the root url or anything else.

This is the configuration for /mysecondapp:

location /mysecondapp {
    proxy_pass http://mysecondapp.local;
}

How can I do that?

I tried to put the first location inside the second one, but that didn't do the trick.

Thank you for the help!

h_h10a
  • 449
  • 5
  • 18
  • Remove the first location block and leave only the second one. – IVO GELOV Jul 28 '21 at 16:36
  • But I want to go to http://mysecondapp.local even if the url doesn't include /mysecondapp but it's coming from /mysecondapp (the referer) – h_h10a Jul 28 '21 at 16:39
  • Location blocks do not work with the `referrer` HTTP header - they only look at the URL path. – IVO GELOV Jul 28 '21 at 16:42
  • @h_h10a Look at [this](https://stackoverflow.com/a/62840133/7121513) answer, first example (Using conditional routing based on HTTP `Referer` header value). Be careful - this technique works well only with SPA (single page applications). – Ivan Shatsky Jul 29 '21 at 20:49

0 Answers0