Search code examples
apachesession-cookieshttp-proxy

HTTP session unavailable while running through domain name


I made a Chess web game (in Dart), deploying to Linux + Apache (behind a proxy). When accessing with public IP, the game ran smoothly. However, when accessing through domain name, the game failed to run. I used both cookie (for token) and HTTP session (for game data), matching this token between cookie and HTTP session.

Here is my Apache setting:

<VirtualHost *:80>
    ServerName example.com

    RewriteEngine On
    RewriteCond %{HTTP:Authorization} ^(.*)
    RewriteRule .* - [e=HTTP_AUTHORIZATION:%1]

    ProxyPreserveHost On
    ProxyPass / http://127.0.0.1:8080/
    ProxyPassReverse / http://127.0.0.1:8080/
</VirtualHost>

I think the issue might be from cookie behind Apache proxy. Any suggestion?


Solution

  • You may need ProxyPassReverseCookieDomian to make sure the domain= in your session cookie is self-referential. Looking at the actual headers sent in e.g. developer tools would probably make it clear.