0

I have a site running on localhost:8001 and I would like it to be accessible on different paths. I need to extract part of the path using regex.

This does work:

server { location /user/amy/ { proxy_pass http://localhost:8001/; } } 

(but it breaks if I remove the slash after 8001).

However, the username can be dynamic, for example:

mydomain.com/user/amy/ --> localhost:8081/ mydomain.com/user/bob/foo --> localhost:8081/foo 

In both cases I want to get the username out in order to do a subrequest. Here is what I have tried:

server { location ~ ^/user/([a-z]+)/(.*)$ { set $user $1; # do stuff with this later proxy_pass http://localhost:8001/$2; } } 

It doesn't work: I get a too many redirects error. I've tried many things and nothing seems to work. I want it to work exactly like the prefix example I gave first, except that I extract the username for further processing. Any help would be massively appreciated.

1 Answer 1

-1

I suggest you try Nginx Proxy Manager.

2
  • And so what? Explain how to do this using your "Nginx Proxy Manager". Commented May 31, 2023 at 15:14
  • You add a proxy host and then add custom locations. You will see the option in the Gui of Nginx Proxy Manager Commented Jun 1, 2023 at 16:08

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.