Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have been running into walls with this for a while, so I posted at stackoverflow, and I was pointed over here...

I am attempting to setup multiple IP addresses on Snow Leopard so that I can develop with SSL certificates. I am running XAMPP - I don't know if that is the problem, but I guess I would run into the same problems, considering the built in apache is turned off.

So first up I looked into starting up the IPs on start up. I got up an running with a new StartupItem that runs correctly, because I can ping the ip address:

ping 127.0.0.2
ping 127.0.0.1

And both of them work. So now I have IP addresses, which as you may know are not standard on OSx.

I edited the /etc/hosts file to include the new sites too:

127.0.0.1    site1.local
127.0.0.2    site2.local

I had already changed the httpd.conf to use the httpd-vhosts.conf - because I had a few sites running on the one IP address.

I have edited the vhosts file so a site looks like this:

<VirtualHost 127.0.0.1:80>
  DocumentRoot "/Users/jim/Documents/Projects/site1/web"  
  ServerName site1.local
  <Directory "/Users/jim/Documents/Projects/site1">
    Order deny,allow
    Deny from All
    Allow from 127.0.0.1
    AllowOverride All
  </Directory>
</VirtualHost>

<VirtualHost 127.0.0.1:443>
  DocumentRoot "/Users/jim/Documents/Projects/site1/web"
  ServerName site1.local
  SSLEngine On
  SSLCertificateFile "/Applications/XAMPP/etc/ssl-certs/myssl.crt"
  SSLCertificateKeyFile "/Applications/XAMPP/etc/ssl-certs/myssl.key"
  SetEnvIf User-Agent ".*MSIE.*" nokeepalive ssl-unclean-shutdown
  <Directory "/Users/jim/Documents/Projects/site1">
    Order deny,allow
    Deny from All
    Allow from 127.0.0.1
    AllowOverride All
  </Directory>
</VirtualHost>

In the above code, you can change the 1's to 2's and it is the setup for the second site. They do use the same certificate, which is why they are on different IP addresses.

I also included the NameVirtualHost information at the top of the file:

NameVirtualHost 127.0.0.1:80
NameVirtualHost 127.0.0.2:80
NameVirtualHost 127.0.0.1:443
NameVirtualHost 127.0.0.2:443

I can ping site1.local and site2.local. I can use telnet ( telnet site2.local 80 ) to get into both sites. But in Safari I can only get to the first site1.local - navigating to site2.local gives me either the localhost main page (which is included in the vhosts) or gives me a Access forbidden!.

I am usure what to do, any suggestions would be awesome.

share|improve this question
add comment

4 Answers

What about listen directive? You should have Listen 127.0.0.1:443 and Listen 127.0.0.2:443 instead of only Listen *:443.

share|improve this answer
add comment

One thing to try: You can have more than one virtualhost use the same certificate on the same IP address as long as you include this directive:

NameVirtualHost 127.0.0.1:443

See http://wiki.apache.org/httpd/NameBasedSSLVHosts for an example configuration file.

share|improve this answer
    
Hey Robert, as you can see in the example I gave, that information is in the vhosts file. Will read the link though, danke. –  Anonymous Nov 23 '09 at 22:20
add comment

I'm not entirely certain that this will solve your "Access forbidden!" problem, but try changing the virtual host tag
from

<VirtualHost 127.0.0.1:80>

to

<VirtualHost _default_:80>

and likewise for :443.

share|improve this answer
add comment

I have the identical setup working, except for my NameVirtualHost, where instead of:

NameVirtualHost 127.0.0.1:80
NameVirtualHost 127.0.0.2:80
NameVirtualHost 127.0.0.1:443
NameVirtualHost 127.0.0.2:443

I only have:

NameVirtualHost *:80

And my ServerName in the HTTPS vhost includes port:443, e.g.

<VirtualHost 127.0.0.1:443>
  DocumentRoot "/Users/jim/Documents/Projects/site1/web"
  ServerName site1.local:443
.........

Hope this helps!

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.