You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Daniel Ruiz <da...@caos.uab.es> on 2008/05/22 12:41:32 UTC
[users@httpd] Problems with rewrite and SSL
Hi,
I'm trying to rewrite a HTTP connection as HTTPS one, but because of the
number of configured virtual hosts, I'm getting problems... I explain here:
- my server has configured 4 virtual hosts: A, B, C and D
- virtual host A has configured into HTTP default site (Debian Etch) a HTTPS
redirection and it works fine. If I connect to A:80, I get a redirection to
A.443 (ssl site) and it is OK.
<VirtualHost A:80>
...
ServerName A
RewriteEngine On
RewriteLog /var/log/apache2/http_rewrite_log
RewriteLogLevel 9
RewriteCond %(SERVER_PORT) !^443$
RewriteRule ^/(.*) https://%{SERVER_NAME}/$1 [L,R]
...
</VirtualHost>
- however, If I connect to B:443, C:443 or D:443, apache runs ssl and, by
default, I run virtual host *:443 and loads A:443. For avoid this, I'm doing
tests with following configurations:
- I'm trying to configure a condition for doing HTTPS rewrite or not
(into ssl site):
<VirtualHost *:443>
...
ServerName A #(<----look at this)
RewriteCond %(SERVER_NAME) !A$ #(in other words, if I'm
trying to connect with SSL support to a site with no SSL support)
RewriteRule ^/(.*) http://%{SERVER_NAME}/$1 [L,R] #(I do a
rewrite to a normal HTTP connection
...
- but with this configuration, I have the following problem:
- connections to B:443, C:443 or D:443 are correctly rewrite to
B:80, C:80 or D:80 (it is perfect for me!!!) but...
- If I try to connect to A:80, web is not displayed. First
rewrite is done OK, but when it executes *:443, it seems that %{SERVER_NAME}
is not equal to A, so apache does another rewrite to http (a loop?)
- If I try to connect to A:443, the same: %{SERVER_NAME} is not
equal to A
Can anyone help me!?!?!?!?!?!
---------------------------------------------------------------------
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@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: [users@httpd] Problems with rewrite and SSL
Posted by Krist van Besien <kr...@gmail.com>.
On Thu, May 22, 2008 at 12:41 PM, Daniel Ruiz <da...@caos.uab.es> wrote:
> Can anyone help me!?!?!?!?!?!
You probably should use %{HTTP_HOST} in stead of %{SERVER_NAME}.
HTTP_HOST is the variable where the "host" header is stored.
A note about this part of your config:
> <VirtualHost A:80>
> ...
> ServerName A
> RewriteEngine On
> RewriteLog /var/log/apache2/http_rewrite_log
> RewriteLogLevel 9
> RewriteCond %(SERVER_PORT) !^443$
> RewriteRule ^/(.*) https://%{SERVER_NAME}/$1 [L,R]
> ...
> </VirtualHost>
You don't need the rewritecond here as SERVER_PORT will always be 80...
Krist
--
krist.vanbesien@gmail.com
krist@vanbesien.org
Bremgarten b. Bern, Switzerland
--
A: It reverses the normal flow of conversation.
Q: What's wrong with top-posting?
A: Top-posting.
Q: What's the biggest scourge on plain text email discussions?
---------------------------------------------------------------------
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@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org