Heya guys,
I have run into a frustrating situation with what I expected to be a completely simple operation, and I was wondering if anyone out there might have some ideas.
We are using a fairly bogstandard Haproxy LB and Apache server setups in our ec2 deployments. I am trying to do something that seems like it should be very simple -- That is: Redirect all requests that come in to a specific http URL (http://example.com/dir1/dir2/signin) to the https version of the same url (https://example.com/dir1/dir2/singnin).
I have a fair amount of experience with mod_rewrite, and I have tried to do this ordinarily very simple operation in every way that I can think of in the App server's .vhost file. However, no matter what I do, the operation ends up looping. Essentially, the first rewrite is successful, and [
......] DOES correctly redirect to [
...,...] but then it just loops and loops, repeatedly redirecting to https:// again and again, ignoring any attempt I make to limit the rule by RewriteConds that specify only to run the rule on non-HTTPS/non-Port 443, etc.
For instance:
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^/dir1/dir2/signin$ "https://%{HTTP_HOST}/dir1/dir2/signin" [R=301,L]
or:
RewriteCond %{HTTPS} !=on
RewriteRule ^/dir1/dir2/signin$ "https://example.com/dir1/dir2/signin" [R=301,L]
(these are not the only things I have tried, not by a long shot, but just wanted to give you an illustrative example)
Have you any idea why this problem is happening and how we can get this simple operation to actually work? We're not trying to do anything complicated or weird, and it seems like other people must have encountered the same issue, no?
I am pretty sure that it is the configuration of haproxy that is causing this to happen. Apache on the LB is configured to just take everything that comes into it on port 80 or port 443 and shove it through to haproxy (127.0.0.1:85). Apache on the LB has two separate .vhost files, one for connections on port 80, and one for connections on port 443.
Thanks, any information you can provide would be very much appreciated,
- Luke