So I've got a kind of complicated Drupal install, but hopefully the hive mind will be able to help me figure this out. (I've been at it for hours with no real progress.)
I have a multisite install of of Drupal 6. Each site has two urls that can access the site, a custom domain and a subdomain of our primary domain. We use a reverse proxy to connect one to the other on the same server.
Initially, we were using the custom domain as the primary and the subdomain as the secondary. Recently we switched those for all new sites. (This helps prevent problems where users wouldn't update their DNS for weeks and the site would be inaccessible.)
Here's a sample of the Apache conf with the custom url as the primary:
<VirtualHost *:80>
ServerAdmin info@mysite1.com
DocumentRoot /var/www/html
ServerName mysite1.com
ServerAlias www.mysite1.com
RewriteEngine On
RewriteOptions inherit
</VirtualHost>
<VirtualHost *:80>
ServerName mysite1.oursite.com
ProxyRequests Off
ProxyPreserveHost Off
ProxyPass / http://www.mysite1.com/
ProxyPassReverse / http://www.mysite1.com/
</VirtualHost>Here's one with the subdomain as the primary:
<VirtualHost *:80>
ServerAdmin info@mysite2.oursite.com
DocumentRoot /var/www/html
ServerName mysite2.oursite.com
RewriteEngine On
RewriteOptions inherit
</VirtualHost>
<VirtualHost *:80>
ServerName www.mysite2.com
ProxyRequests Off
ProxyPreserveHost Off
ProxyPass / http://mysite2.oursite.com/
ProxyPassReverse / http://mysite2.oursite.com/
</VirtualHost>
For some reason, the latter doesn't work. The site can be accessed and browsed normally, but users cannot log in through the custom domain. The session is getting lost somehow.
But the other configuration - with the custom url proxying to the subdomain - works perfectly!
Any ideas why?
Thank you.
Comments
Follow up: Further research
Follow up:
Further research has shown that in the non-working instances, all cookie data is being assigned to the subdomain. I added some code to dump the contents of $_COOKIE into the watchdog table at the start of sess_read.
When I access mysite2.com, the cookie contains no session information
var_export($_COOKIE);array ( 'has_js' => '1', )When I access mysite2.oursite.com, the cookie contains the session information for both the custom URL and the subdomain:
var_export($_COOKIE);array ( 'SESSfb3942de15cca1710e8ac408c1480f7f' => 'q0i4fj8nv44to77qt85j0lrma7', 'has_js' => '1', 'SESS90054b21872cd2e8fe70ff3fc8fd94fe' => '1p0uc0u2bf633h7k5ms75fjhl7', )Figured it out! The cookie
Figured it out!
The cookie was not getting passed through with the right name. It was coming through as ".oursite.com"
ProxyPassReverseCookieDomain to the rescue! (Also, the Rewrite directives should go in the second virtual host, not the first.)