The goal
Make all requests to a previously static page at https://www.example.com/sub/folder on server 1 (Proxy) ACTUALLY go to a Drupal site at https://other.example.com on server 2 (Origin)
This is also getting setup as a multisite, because there are sub/folder2, sub/folder3, etc. that will need to be converted to Drupal sites. I don't think this has anything to do with the problem, but for the sake of completeness, I'm adding the sites.php changes too below.
What I've done so far
Changes on Server 1 (Proxy): Apache config
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} ^/sub/folder
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
SSLProxyEngine On
<Location /sub/folder>
ProxyPass https://other.example.com/
ProxyPassReverse https://other.example.com/
ProxyPassReverseCookiePath / /sub/folder
</Location>
Changes on Server 2 (Origin): settings.php and sites.php
sites.php (because of multisite; and sites/sitename/settings.php is the file I'll be referencing below)
$sites['other.example.com'] = 'sitename';
$sites['www.example.com.sub.folder'] = 'sitename'; // I don't think this one is necessary, but just in case?
Aside from the standard DB setup in settings.php, the following has been added:
// $base_url allows for links/URIs to be generated properly
// Changing the REQUEST_URI seems to have fixed form issues, like the search block/form
// Not sure if the cookie_domain is doing anything/working properly
if (isset($_SERVER['HTTP_X_FORWARDED_HOST']) && $_SERVER['HTTP_X_FORWARDED_HOST'] == 'www.example.com') {
$base_url = 'https://www.example.com/sub/folder'; // NO trailing slash!
$_SERVER['REQUEST_URI'] = '/sub/folder' . $_SERVER['REQUEST_URI'];
// (Edit) note don't put 'http' in front of this
$cookie_domain = '.other.example.com';
}
...
$conf['reverse_proxy'] = TRUE;
...
$conf['reverse_proxy_addresses'] = array('ip.of.origin.server');
The problems
- Trying to login through www.example.com/sub/folder/user validates (according to Drupal log)... but then it treats the page re-load as an anonymous user and fails access. Presumably, the cookie gets broke/lost/invalidated somehow in between. So, authenticated access to the server has to be done through other.example.com Not a huge problem (since the average Joe won't be logging in), but...
- There's just a lot of annoying things occuring having to deal with fixing user/content created links and URIs. Currently, links that are first viewed after a cache clear are cached as whatever domain they're being viewed from. (This happened from using Pathologic module to force absolute URLs.) I realize this might not have been the BEST solution--using Pathologic--but if I fix problem 1., this should become a moot point.
So, I think I've got some kind of SSL/Proxy cookie issue at this point... any suggestions?