1

Here is the configuration for my reverse proxy server:

server { listen 8085 ssl; server_name localhost; location / { proxy_pass http://192.168.85.56:8080; } } 

For an incoming path, e.g.: https://localhost:8085/path1/1/path2/, I want to remove the /1/, so the resulting path will be https://localhost:8085/path1/path2/.

One constraint is that path1 can change to any string.

Also, matching on any number instead of just 1 is also a valid solution.

How can this be done?

Edit: My problem is very similar to this one, except that I have a string, path1, that can vary.

1 Answer 1

0

Use a rewrite...break inside the location block.

For example:

location / { rewrite ^(.*)/[0-9]+/(.*)$ $1/$2 break; proxy_pass http://192.168.85.56:8080; } 

See this document for details.

1
  • It worked with one caveat. The server I am running is a Spark history server and with this solution, I need to click the links to each "application history data" twice. Once a link has been clicked, it does not need to be clicked twice again. I suppose the /1/ tells the server to load the history data into memory. Is there any workaround for this? Commented Nov 21, 2019 at 8:00

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.