0

I have a server which runs 2 applications. I am using a public IP address and I want to parse the url in a way if a specific text occurs the call is redirect to a specific port. In my case I want that if the url contains:

  • /myapp1/a1 -> port 82
  • /myapp2/a2 -> port 81

examples: Supposing my public ip is p.u.b.l, my private ip is p.r.i.v, the following URLs should be resolved by the server in this way:

http://p.u.b.l./myapp1/a1/something -> http://p.r.i.v.:82/myapp1/a1/something http://p.u.b.l./myapp2/a2/something -> http://p.r.i.v.:81/myapp2/a2/something

I am trying to configure Apache in a way to provide reverse proxy. Following my configuration in site-availables, also added in site-enabled:

ServerName p.r.i.v ProxyPassMatch "/myapp1/a1(.*)$" "http://p.r.i.v:82/myapp1/a1/$1" ProxyPassReverse "/myapp1/a1(.*)$" "http://p.r.i.v:82/myapp1/a1/$1" ProxyPassMatch "/myapp2/a2(.*)$" "http://p.r.i.v:81/myapp2/a2/$1" ProxyPassReverse "/myapp2/a2(.*)$" "http://p.r.i.v:81/myapp2/a2/$1" 

But the redirect is not working. What am I missing? Please consider the direct access to the private resource works, meaning http://p.r.i.v:81/myapp2/a2/something, but the http://p.u.b.l/myapp2/a2/something is not resolved

Any help is appreciated Thanks Simone

2
  • I think you don't need regex matching and can do with a "simple" ProxyPass: ProxyPassMatch "/myapp1/a1/" "http://p.r.i.v:82/myapp1/a1/" and ProxyPassReverse "/myapp1/a1/" "http://p.r.i.v:82/myapp1/a1/" and don't forget to balance in both the URL and target the trailing / when you add/omit those Commented Nov 19, 2018 at 12:09
  • Hi @HBruijn, I've used the ProxyPass as suggested but I received no improvement. Thanks Commented Nov 19, 2018 at 13:29

1 Answer 1

1

the issue is resolved. In the proxied url there was an encoded char, which needed a proper definition. In this case, I added AllowEncodedSlashes On and nocanon next to the ProxyPass and ProxyPassReverse rules.

Thanks Simone

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.