Apache server not able to read cookies from Browser

8,493

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.

Share:
8,493

Related videos on Youtube

Drew
Author by

Drew

Updated on September 18, 2022

Comments

  • Drew
    Drew over 1 year

    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

    localhost:8080 
    

    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
    

    and

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

    Please let me know what am I doing wrong

  • Drew
    Drew about 11 years
    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
  • Drew
    Drew about 11 years
    I think I need to use Apache 2.2 if I need to use ProxyPassReverseCookiePath. Isn't it?
  • Drew
    Drew about 11 years
    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