I have developed a login authentication page using cookies (with spring security) where for the first time, the user will need to get itself authenticated. Once the user gets successfully authenticated, then on each subsequent request from the same browser, the user will redirected to the success page. The code is working fine on


but the problem is I have configured Apache HTTP server and when I hit the request through the Apache server to the application, then I think the cookies are not been read by the Apache server.

I have enabled the cookies in httpd.conf file (but it is not working) as well by

LoadModule usertrack_module modules/mod_usertrack.so


<VirtualHost *>
    ServerName localhost
    CookieTracking on
    ProxyPass / http://localhost:8080/stackoverflow/

Please let me know what am I doing wrong

1 Answer 1


Your server on localhost is most likely writing the cookies for localhost, or for the stackoverflow directory. When it is accessed from behind a reverse proxy, it needs to recognize this and set the cookies the correct domain name.

Instead of the smarts for this residing in the web app on port 8080, you could have the reverse proxy translate the cookies:

ProxyPassReverseCookiePath /stackoverflow /
ProxyPassReverseCookieDomain localhost example.com

See this question on StackOverflow where I asked about jsessionid cookies and used this technique on the reverse proxy to solve my problem.

  • I have added ProxyPassReverseCookiePath in httpd.conf but it is giving me "invalid command" error on console. Which LoadModule do it need for this. I already have mod_proxy uncommented in the httpd.conf file
    – Bhuvan
    Commented Mar 19, 2013 at 3:54
  • I think I need to use Apache 2.2 if I need to use ProxyPassReverseCookiePath. Isn't it?
    – Bhuvan
    Commented Mar 19, 2013 at 4:38
  • Its working now.. Thanks Stephen so much.. I don't have enough reputations to give an up-vote here but will be giving it to you on your question in Stackoverflow. Thanks again
    – Bhuvan
    Commented Mar 19, 2013 at 5:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.