5

I have a server with an Apache reverse proxy in front. The server machine contains 2 web applications running under:

  • localhost:8000/app and exposed as my.url.com/app1
  • localhost:8001/app and exposed as my.url.com/app2

They are essentially different versions of the webapp and we want them both up. Both webapps create a cookie like so:

Set-Cookie: sessionid=as7d86fa98sg67; Path=/app; HttpOnly

Note that there is no Domain property on the cookie header.

I have added 2 different ProxyPassReverseCookiePath directives like so:

  • ProxyPassReverseCookiePath /app /app1
  • ProxyPassReverseCookiePath /app /app2

The goal is that each webapp will have its Path=/app transformed to the appropriate context. However the ProxyPassReverseCookiePath directives seem to override one another and don't have awareness of the webapp they run for.

TL;DR:

ProxyPass /app1/ http://localhost:8000/app/ ProxyPassReverse /app1/ http://localhost:8000/app/ ProxyPassReverseCookiePath /app /app1 ProxyPass /app2/ http://localhost:8001/app/ ProxyPassReverse /app2/ http://localhost:8001/app/ ProxyPassReverseCookiePath /app /app2 

This configurations works, except for the cookie path property. For both cases it gets replaced with Path=/app1/ whereas I'd like it to be specific to each app that handles the request.

1 Answer 1

5

After searching around the solution is to group the directives under a <Location> tag:

<Location /app1> ProxyPassReverseCookiePath /app /app1 </Location> <Location /app2> ProxyPassReverseCookiePath /app /app2 </Location> 

This way Apache knows to properly apply each directive depending on the origin of the response.

2
  • It seems the other parts ProxyPass and ProxyPassReverse can go inside the Location. In your test you put just the ProxyPassReverseCookiePath? Commented Apr 16, 2023 at 11:40
  • I'm not sure, I don't remember (it's been a few years) but I guess it's not mandatory. Whatever works for you. Commented Apr 18, 2023 at 13:28

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.