Re: Re[users@httpd] direct to HTTPS using Load Balancer/SSL Offload

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Indeed, just my 2 cents since I've had the similar issue - I wanted to
redirect all http traffic to https:

My loadbalancer forwards http traffic to Apache on port 80. 
SSL accelerator forwards decrypted https traffic to Apache on port 81.

Apache is listening on both 80 and 81:

Listen 80
Listen 81

My first attempt was to use the following mod_rewrite rule:

RewriteEngine On
RewriteCond % {SERVER_PORT} ^80$
RewriteRule ^/(.*)$ https:/%{HTTP_HOST}/$1 [L,R]

However for some reason, SERVER_PORT always matched, even when traffic came
through port 81. Adding %p (%...p The canonical port of the server serving
the request ) for the log as such

LogFormat %p Combined
CustomLog log/access_log combined

revealed only port 80 in the log for all traffic, even when traffic came in
on port 81. This was quite confusing, or it's just me not fully
understanding of Apache's internal work.

My solution was as suggested, setup two virtual hosts as such:

<VirtualHost *:80>
RewriteEngine On
RewriteRule ^/*(.*)$ https://%{HTTP_HOST}/$1 [L,R]
</VirtualHost>

<VirtualHost *:81>
#...do some other stuff here
</VirtualHost>

Tada.


-- 
View this message in context: http://www.nabble.com/Redirect-to-HTTPS-using-Load-Balancer-SSL-Offload-tf4864401.html#a13947270
Sent from the Apache HTTP Server - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx
   "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx


[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux