You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Alain Roger <ra...@gmail.com> on 2012/05/26 13:56:33 UTC

[users@httpd] trouble with virtualhost in http/https

Hi,

i have some issues with virtualhosts in http and https on windows 7.
basically i have 2 virtualhost using http/https and setup as following:

[code]#--------------------------
# website1 with Joomla 2.5
#--------------------------
<VirtualHost *:80>
  DocumentRoot "d:/webserver/www/website1"
  ServerName website1.loc
  ServerAlias www.website1.loc
  ErrorLog "logs/website1.loc.error.log"
  CustomLog "logs/website1.loc.access.log" common

  AccessFileName .htaccess

  <Directory "d:/webserver/www/website1/">
    AllowOverride All
    Order deny,allow
    Deny from all
    Allow from 192.168.x.x
    Allow from 127.0.0.1
  </Directory>
</VirtualHost>

<VirtualHost website1.loc:443>
  DocumentRoot "d:/webserver/www/website1"
  ServerName website1.loc
  ServerAlias www.website1.loc
  ErrorLog "logs/website1.loc.error.log"
  CustomLog "logs/website1.loc.access.log" common

      SSLEngine on
    SSLCertificateFile conf/ssl.crt/server.crt
    SSLCertificateKeyFile conf/ssl.key/server.key

  AccessFileName .htaccess

  <Directory "d:/webserver/www/website1/">
    AllowOverride All
    Order deny,allow
    Deny from all
    Allow from 192.168.1.x
    Allow from 127.0.0.1
  </Directory>

</VirtualHost>

#--------------------------
# website2 with Joomla 2.5
#--------------------------
<VirtualHost *:80>
  DocumentRoot "d:/webserver/www/website2"
  ServerName website2.loc
  ServerAlias www.website2.loc
  ErrorLog "logs/website2.loc.error.log"
  CustomLog "logs/website2.loc.access.log" common

  AccessFileName .htaccess

  <Directory "d:/webserver/www/website2/">
    AllowOverride All
    Order deny,allow
    Deny from all
    Allow from 192.168.x.x
    Allow from 127.0.0.1
  </Directory>
</VirtualHost>

<VirtualHost website2.loc:443>
  DocumentRoot "d:/webserver/www/website2"
  ServerName website2.loc
  ServerAlias www.website2.loc
  ErrorLog "logs/website2.loc.error.log"
  CustomLog "logs/website2.loc.access.log" common

      SSLEngine on
    SSLCertificateFile conf/ssl.crt/server.crt
    SSLCertificateKeyFile conf/ssl.key/server.key

  AccessFileName .htaccess

  <Directory "d:/webserver/www/website2/">
    AllowOverride All
    Order deny,allow
    Deny from all
    Allow from 192.168.1.x
    Allow from 127.0.0.1
  </Directory>

</VirtualHost>
[/code]

in my host file i have:
www.website1.loc   192.168.1.x
website1.loc   192.168.1.x
www.website2.loc   192.168.1.x
website2.loc   192.168.1.x

1. now when in my browser i type website2.loc i have an error 500
2. if instead of using <VirtualHost *:80> i use <VirtualHost
website1.loc:80> and <VirtualHost website2.loc:80> respectively for
website1 and website2.... only website1.loc works :(
so where is my mistake ?
thx.

-- 
Alain
-----------------------------------------------------------
Windows 7 x64 / Fedora 16 x64
PostgreSQL 8.3.5 / MySQL 5
Apache 2.2.16
PHP 5.3.1
C# 2005-2008

Re: [users@httpd] trouble with virtualhost in http/https

Posted by Bill Unruh <un...@physics.ubc.ca>.
On Sat, 26 May 2012, Alain Roger wrote:

> I did as in the documentation:
> # Ensure that Apache listens on port 80
> Listen 80
>
> # Listen for virtual host requests on all IP addresses
> NameVirtualHost *:80
>
> <VirtualHost *:80>
> DocumentRoot /www/example1
> ServerName www.example1.com
>
> # Other directives here
>
> </VirtualHost>
>
> <VirtualHost *:80>
> DocumentRoot /www/example2
> ServerName www.example2.org
>
> # Other directives here
>
> </VirtualHost>
>
> everything in the httpd-vhosts.conf file of xampp... but both website have
> https...and basically the first defined is the default one...and this is
> something i can't allow...
> so how to do to be sure that if user is in http://www.website2..loc and
> select clicks on link as https...he goes to https://www.website2.loc and
> not https://www.website1.loc ?

Make the same things for port 443
Listen 443

<VirtualHost *:443>
  DocumentRoot /www/example2
  ServerName www.example2.org

  # Other directives here

  </VirtualHost>

Or do both
http://httpd.apache.org/docs/2.0/vhosts/examples.html
>
> thx
>
> On Sat, May 26, 2012 at 6:11 PM, Eric Covener <co...@gmail.com> wrote:
>
>> your putting hostnames in <virtualhost> instead of using name-based
>> virtualhosts but this doesn't work as you expect.
>>
>> Try mimicing the examples in the manual and using
>>
>> NameVirtualHost *:80
>> <virtualost *:80>
>> ...
>> <virtualost *:80>
>> ...
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>> For additional commands, e-mail: users-help@httpd.apache.org
>>
>>
>
>
>

-- 
William G. Unruh   |  Canadian Institute for|     Tel: +1(604)822-3273
Physics&Astronomy  |     Advanced Research  |     Fax: +1(604)822-5324
UBC, Vancouver,BC  |   Program in Cosmology |     unruh@physics.ubc.ca
Canada V6T 1Z1     |      and Gravity       |  www.theory.physics.ubc.ca/

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] trouble with virtualhost in http/https

Posted by Frank Gingras <fr...@gmail.com>.

On 06/06/2012 05:51 AM, Pete Houston wrote:
> You cannot have 2 https sites with different certificates sharing the
> same IP+port combination. This is a restriction of how https works and
> is outlined in the documentation here:
> http://httpd.apache.org/docs/2.4/ssl/ssl_faq.html#vhosts
>
> If you ensure that your https vhosts have either different IP addresses
> or different ports then they can be correctly served.
>
> Pete
>
> On Sat, May 26, 2012 at 09:43:18PM +0200, Alain Roger wrote:
>> I did as in the documentation:
>> # Ensure that Apache listens on port 80
>> Listen 80
>>
>> # Listen for virtual host requests on all IP addresses
>> NameVirtualHost *:80
>>
>> <VirtualHost *:80>
>> DocumentRoot /www/example1
>> ServerName www.example1.com
>>
>> # Other directives here
>>
>> </VirtualHost>
>>
>> <VirtualHost *:80>
>> DocumentRoot /www/example2
>> ServerName www.example2.org
>>
>> # Other directives here
>>
>> </VirtualHost>
>>
>> everything in the httpd-vhosts.conf file of xampp... but both website have
>> https...and basically the first defined is the default one...and this is
>> something i can't allow...
>> so how to do to be sure that if user is in http://www.website2..loc and
>> select clicks on link as https...he goes to https://www.website2.loc and
>> not https://www.website1.loc ?
>

Actually, that's incorrect. You can do so, and provided that you use SNI 
and SNI-capable HTTP clients, the correct certificate will be used, too!

Just set up regular *:443 name-based vhosts.

Frank

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] trouble with virtualhost in http/https

Posted by Pete Houston <ph...@openstrike.co.uk>.
You cannot have 2 https sites with different certificates sharing the
same IP+port combination. This is a restriction of how https works and
is outlined in the documentation here:
http://httpd.apache.org/docs/2.4/ssl/ssl_faq.html#vhosts

If you ensure that your https vhosts have either different IP addresses
or different ports then they can be correctly served.

Pete

On Sat, May 26, 2012 at 09:43:18PM +0200, Alain Roger wrote:
> I did as in the documentation:
> # Ensure that Apache listens on port 80
> Listen 80
> 
> # Listen for virtual host requests on all IP addresses
> NameVirtualHost *:80
> 
> <VirtualHost *:80>
> DocumentRoot /www/example1
> ServerName www.example1.com
> 
> # Other directives here
> 
> </VirtualHost>
> 
> <VirtualHost *:80>
> DocumentRoot /www/example2
> ServerName www.example2.org
> 
> # Other directives here
> 
> </VirtualHost>
> 
> everything in the httpd-vhosts.conf file of xampp... but both website have
> https...and basically the first defined is the default one...and this is
> something i can't allow...
> so how to do to be sure that if user is in http://www.website2..loc and
> select clicks on link as https...he goes to https://www.website2.loc and
> not https://www.website1.loc ?

-- 
Openstrike - improving business through open source
http://www.openstrike.co.uk/ or call 01722 770036 / 07092 020107

Re: [users@httpd] trouble with virtualhost in http/https

Posted by Alain Roger <ra...@gmail.com>.
I did as in the documentation:
# Ensure that Apache listens on port 80
Listen 80

# Listen for virtual host requests on all IP addresses
NameVirtualHost *:80

<VirtualHost *:80>
DocumentRoot /www/example1
ServerName www.example1.com

# Other directives here

</VirtualHost>

<VirtualHost *:80>
DocumentRoot /www/example2
ServerName www.example2.org

# Other directives here

</VirtualHost>

everything in the httpd-vhosts.conf file of xampp... but both website have
https...and basically the first defined is the default one...and this is
something i can't allow...
so how to do to be sure that if user is in http://www.website2..loc and
select clicks on link as https...he goes to https://www.website2.loc and
not https://www.website1.loc ?

thx

On Sat, May 26, 2012 at 6:11 PM, Eric Covener <co...@gmail.com> wrote:

> your putting hostnames in <virtualhost> instead of using name-based
> virtualhosts but this doesn't work as you expect.
>
> Try mimicing the examples in the manual and using
>
> NameVirtualHost *:80
> <virtualost *:80>
> ...
> <virtualost *:80>
> ...
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
>


-- 
Alain
-----------------------------------------------------------
Windows 7 x64 / Fedora 14 x64
PostgreSQL 8.3.5 / MySQL 5
Apache 2.2.16
PHP 5.3.1
C# 2005-2008

Re: [users@httpd] trouble with virtualhost in http/https

Posted by Eric Covener <co...@gmail.com>.
your putting hostnames in <virtualhost> instead of using name-based
virtualhosts but this doesn't work as you expect.

Try mimicing the examples in the manual and using

NameVirtualHost *:80
<virtualost *:80>
...
<virtualost *:80>
...

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org