Forum Moderators: phranque

Message Too Old, No Replies

redirect that no longer works with new version of mod_ssl

         

dfinn

7:28 pm on Mar 16, 2004 (gmt 0)

10+ Year Member



We recently built a new web server and are slowly moving sites over to it. It's running
Apache/1.3.26 (Unix) Debian GNU/Linux mod_ssl/2.8.9 OpenSSL/0.9.6g PHP/4.1.2

our first ssl site that we moved over gaves us alot of trouble. we were able to determine that it was due to the following lines in httpd.conf:
<VirtualHost *:443>
ServerName www.domain.org
Redirect / [domain.org...]
</VirtualHost>

which were causing the following error with mod_ssl:
[15/Mar/2004 15:30:30 22545] [warn] Init: (www.domain.org:443) You c
onfigured HTTP(80) on the standard HTTPS(443) port!

when we comment those lines out of httpd.conf out everything starts up and works fine. we had that redirect in place to catch anyone trying to go to [domain.org...] and redirect them to [domain.org...] because our ssl certificat is only for ssl.domain.org.

I also tried adding:
SSLEngine off
into that vhost section but that didn't help.

Is there a fix or a work around for this?
or do I need to resort to mod_rewrite? If that is the case what would the correct mod_rewrite statement(s) look like for this.

Thanks ahead of time.
Dan

closed

4:05 am on Mar 17, 2004 (gmt 0)

10+ Year Member



Welcome to WebmasterWorld, dfinn!

I don't really know why you're getting that error, but if you do plan to use mod_rewrite, the code would be pretty simple. If SERVER_PORT is 443, redirect to

http://www.domain.org
.

dfinn

5:10 pm on Mar 17, 2004 (gmt 0)

10+ Year Member



hmm...i tried this but it didn't seem to work :

RewriteEngine on
RewriteLog /tmp/blah.txt
RewriteLogLevel 3
RewriteCond %{HTTPS} ^on$
RewriteCond %{HTTPS_HOST}!ssl.domain.org$ [NC]
RewriteRule %{HTTPS_HOST} [domain.org...] [L,NC]

it's also not writing anything to the log file.

closed

5:16 pm on Mar 17, 2004 (gmt 0)

10+ Year Member



Well, none of the variables you used in the code you just posted are actually valid. The mod_rewrite documentation [httpd.apache.org] has a list of the variables you can use.

dfinn

5:30 pm on Mar 17, 2004 (gmt 0)

10+ Year Member



ok, i think this might be closer to what i want. sorry for not RTFM the first time around:

RewriteEngine on
RewriteLog "/tmp/blah.txt"
RewriteLogLevel 3
RewriteCond %{SERVER_PORT} ^443$
RewriteCond %{HTTP_HOST} !ssl.domain.org$ [NC]
RewriteRule %{HTTP_HOST} [domain.org...] [L,NC]

if it's coming in on port 443 and they aren't asking for ssl.domain.org send them to www.domain.org. look ok?

closed

5:42 pm on Mar 17, 2004 (gmt 0)

10+ Year Member



Close, but not quite right.

If you want to match dots in regular expressions, you'll want to escape them. It would work the way you have it right now, but obviously the more correct way is better.

Also, the syntax for RewriteRule is:

RewriteRule Pattern Substitution

I'm not sure if the RewriteRule you posted will actually work. I would have just used a pattern that matches all files, then redirect to

www.domain.org
.

dfinn

5:47 pm on Mar 17, 2004 (gmt 0)

10+ Year Member



RewriteEngine on
RewriteLog "/tmp/blah.txt"
RewriteLogLevel 3
RewriteCond %{SERVER_PORT} ^443$
RewriteCond %{HTTP_HOST} !ssl\.domain\.org$ [NC]
RewriteRule ^/$ [domain.org...] [L,NC]

for whatever reason it's still not logging for me and I'm not sure that it's working at all.

dfinn

5:56 pm on Mar 17, 2004 (gmt 0)

10+ Year Member



here's what i'm trying:

In my main httpd.conf I have:
RewriteEngine On
RewriteLogLevel 3
RewriteLog /var/log/apache/mod_rewrite.log

Include /etc/apache/conf.d

inside the conf.d directory there is a file for each of my vhosts.

I have tried putting the following at the top of the file for this vhost:
RewriteEngine on
RewriteLog "/tmp/blah.txt"
RewriteLogLevel 3
RewriteCond %{SERVER_PORT} ^443$
RewriteCond %{HTTP_HOST} !ssl\.nevadaart\.org$ [NC]
RewriteRule ^/$ [nevadamuseumofart.org...] [L,NC]

but it's not recognizing that for whatever reason. It's not logging anywhere and it's not doing the reidrect. I created a .htaccess under the ssl section of the vhosts htdocs and put the above rewrite statements, conditions and rewrite in it and it sees that but it gives me the following error:
[Wed Mar 17 09:46:11 2004] [alert] [client 1.2.3.4] /home/jail/www.domain.org/www/ssl/.htaccess: RewriteLog not allowed here

for each of RewriteLog, RewriteCond and RewriteRule.

I did make sure to add :
AllowOverride AuthConfig
to the directory.

Am I missing a step?

closed

6:09 pm on Mar 17, 2004 (gmt 0)

10+ Year Member



Addressing issues in post sent at 5:47 pm:

If you're going to match all files, you should replace this:

^/$

with this:

.*

Besides, if you're putting your code in .htaccess, the path you match the pattern against doesn't usually begin with a slash.

Since there aren't actually any letters in the pattern, the

NC
flag is useless so you should remove it.

Also, because you're doing an external redirect, you should use the

R
flag.

Addressing issues in post sent at 5:56 pm:

If you check the mod_rewrite documentation, you'll find that the use RewriteLog is not permitted in .htaccess.

dfinn

6:11 pm on Mar 17, 2004 (gmt 0)

10+ Year Member



i'd rather not use .htaccess files for this but for whatever reason it's not recognizing it when I put them in the apache vhost config files.

closed

6:13 pm on Mar 17, 2004 (gmt 0)

10+ Year Member



Have you made the changes I recommended in my previous post?

dfinn

6:17 pm on Mar 17, 2004 (gmt 0)

10+ Year Member



I have. I really appreciate all of your help. It's now working if I use a .htaccess file. It does not work when I remove that .htaccess file and try to specify it in the config. I'm trying to figure that out now. Any ideas?

dfinn

6:20 pm on Mar 17, 2004 (gmt 0)

10+ Year Member



I got it. I was specifying the mod_rewrite rules outside of the vhost container. I put them inside and it all works now. Thanks again for all your help. Hopefully this will be able to help someone else in the future.

closed

6:28 pm on Mar 17, 2004 (gmt 0)

10+ Year Member



You're welcome, dfinn. Hopefully it will.

dfinn

6:46 pm on Mar 17, 2004 (gmt 0)

10+ Year Member



One last question. I think the answer is No but I'm going to ask anyways.

When I hit [domain.org...] I do get redirected to [domain.org...] but I get prompted or warned from my browser that the ssl cert is for ssl.domain.org but i'm going to www.domain.org. Is there any way to avoid this. I'm guessing there isn't because the ssl negotiation is happening first before the redirect happens correct?

closed

8:36 pm on Mar 17, 2004 (gmt 0)

10+ Year Member



I'm not sure. You could probably try putting your mod_rewrite code before this line in your httpd.conf:

<IfModule mod_ssl.c>

If that doesn't work, well, I don't have any better ideas.