Apache Server configuration support - Named Virtual Hosts & 80 or 443

This is Interesting: Free IT Magazines  
Home > Archive > Apache Server configuration support > May 2006 > Named Virtual Hosts & 80 or 443





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Named Virtual Hosts & 80 or 443
deciacco

2006-05-22, 7:16 pm

I know why its happening but I don't know how to fix it.

http://www.mydomain.net/ --> OK
https://www.mydomain.net/ --> I get downloads.mydomain.net instead.

https://downloads.mydomain.net/ --> OK
http://downloads.mydomain.net/ --> I get www.mydomain.net instead.

-------from apache2.conf--------

NameVirtualHost *:80

<VirtualHost *:80>
DocumentRoot /var/www/mydomain.net
ServerName www.mydomain.net
<Directory "/var/www/mydomain.net">
allow from all
#Options +Indexes
</Directory>
</VirtualHost>

NameVirtualHost *:443

<VirtualHost *:443>
DocumentRoot /var/www/downloads.mydomain.net
SSLEngine On
SSLCertificateFile /etc/apache2/ssl/apache.pem
ServerName downloads.mydomain.net
<Directory "/var/www/downloads.mydomain.net">
allow from all
#Options +Indexes
</Directory>
</VirtualHost>

Rich

2006-05-23, 1:19 am

Hi deciacco,

You said you know why it's happening, if that's the can't why can't you fix
it?

You have no VirtualHost directive for http://downloads.mydomain.net. As the
default host points to www.mydomain.net it falls back to that one instead.

Easy and simple solution: Add a virtualhost for downloads.mydomain.net.

Cheers,
Rich

"deciacco" <eugenio@iatmgu.com> wrote in message
news:1148331025.204945.315940@38g2000cwa.googlegroups.com...
>I know why its happening but I don't know how to fix it.
>
> http://www.mydomain.net/ --> OK
> https://www.mydomain.net/ --> I get downloads.mydomain.net instead.
>
> https://downloads.mydomain.net/ --> OK
> http://downloads.mydomain.net/ --> I get www.mydomain.net instead.
>
> -------from apache2.conf--------
>
> NameVirtualHost *:80
>
> <VirtualHost *:80>
> DocumentRoot /var/www/mydomain.net
> ServerName www.mydomain.net
> <Directory "/var/www/mydomain.net">
> allow from all
> #Options +Indexes
> </Directory>
> </VirtualHost>
>
> NameVirtualHost *:443
>
> <VirtualHost *:443>
> DocumentRoot /var/www/downloads.mydomain.net
> SSLEngine On
> SSLCertificateFile /etc/apache2/ssl/apache.pem
> ServerName downloads.mydomain.net
> <Directory "/var/www/downloads.mydomain.net">
> allow from all
> #Options +Indexes
> </Directory>
> </VirtualHost>
>



Davide Bianchi

2006-05-23, 7:18 am

On 2006-05-22, deciacco <eugenio@iatmgu.com> wrote:
> I know why its happening but I don't know how to fix it.
>
> http://www.mydomain.net/ --> OK
> https://www.mydomain.net/ --> I get downloads.mydomain.net instead.
>
> https://downloads.mydomain.net/ --> OK
> http://downloads.mydomain.net/ --> I get www.mydomain.net instead.
>



Since you defined www only on http and download only on https, is obvious
that http://download is handled by the only http vhost defined, and the
other way around.

You should define a Vhost to handle http for downloads that redirect
to https, and a vhost to handle https for www that redirect to http.

I guess that your certificate is for 'mydomain.net', otherwise you'll
receive an error that the certificate doesn't match the servername.

Davide


--
The most exciting phrase to hear in science, the one that heralds new
discoveries, is not "Eureka!" (I found it!) but "That's funny ..."
-- Isaac Asimov
deciacco

2006-05-23, 1:17 pm

Thank you both for yor reply...was right infront of my face...
I knew it was droping to the next available IP, but it had me
confused...

deciacco

2006-05-23, 1:17 pm

Ok...one more quick thing please....
I have changed the hosts like this....if I wanted to give an error
requiring SSL or dropping the request...how would I do that...would I
use mod_rewrite to forward them somewhere else or is there a
better/other method.

Thanks!!

NameVirtualHost *:80

<VirtualHost *:80>
DocumentRoot /var/www/mydomain.net
ServerName www.mydomain.net
<Directory "/var/www/mydomain.net">
allow from all
#Options +Indexes
</Directory>
</VirtualHost>

<VirtualHost *:80>
DocumentRoot "/var/www/downloads.mydomain.net"
ServerName downloads.mydomain.net
<Directory "/var/www/downloads.mydomain.net">
allow from all
Options +Indexes
</Directory>
</VirtualHost>

NameVirtualHost *:443

<VirtualHost *:443>
DocumentRoot /var/www/downloads.mydomain.net
SSLEngine On
SSLCertificateFile /etc/apache2/ssl/apache.pem
ServerName downloads.mydomain.net
<Directory "/var/www/downloads.mydomain.net">
allow from all
#Options +Indexes
</Directory>
</VirtualHost>

<VirtualHost *:443>
DocumentRoot /var/www/mydomain.net
ServerName www.mydomain.net
<Directory "/var/www/mydomain.net">
allow from all
#Options +Indexes
</Directory>
</VirtualHost>

Robert Ionescu

2006-05-25, 7:19 am

deciacco wrote:
> f I wanted to give an error
> requiring SSL or dropping the request...how would I do that...would I
> use mod_rewrite to forward them somewhere else or is there a
> better/other method.


You might use mod_alias to force a redirect to the https protocol inside
your virtual hosts for port 80

Redirect 301 / https://downloads.mydomain.net/
deciacco

2006-05-29, 5:40 pm

Will look into that...Thank you!!

Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2009 webservertalk.com