LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices

Reply
 
LinkBack Search this Thread
Old 05-24-2007, 08:49 PM   #1
neocontrol
Member
 
Registered: Jul 2005
Posts: 271

Rep: Reputation: 31
Apache + Virtual Hosts + SSL = PLEASE HELP


Hi Everyone,

Here's the situation.

I have an apache server that has 4 domains on it. Some use ssl. Some dont. Some use both.

I have your typical name based virtual hosts. They all look similar to this.

Code:
NameVirtualHost *:80
<VirtualHost *:80>
Servername www.domain.com
DocumentRoot /usr/local/apache2/htdocs/domain/
</VirtualHost>
I tried adding this, to make ssl work.

Code:
NameVirtualHost *:443
<VirtualHost *:443>
SSLEngine on
SSLCertificateFile "/usr/local/apache2/conf/server.crt"
SSLCertificateKeyFile "/usr/local/apache2/conf/server.key"
Servername www.domain.com/example/
DocumentRoot /usr/local/apache2/htdocs/domain/example/
</VirtualHost>
So effectively I have both of those in my httpd-vhosts. The regular non ssl site works. The ssl sites doesn't at all. I get a forbidden message. What am I missing here?
 
Old 05-24-2007, 08:58 PM   #2
gilead
Senior Member
 
Registered: Dec 2005
Location: Brisbane, Australia
Distribution: Slackware64 13.37
Posts: 4,021

Rep: Reputation: 125Reputation: 125
You can only have one name based virtual host using SSL. Have you had a look at through the Apache docs at http://httpd.apache.org/docs/2.0/? There's an FAQ on SSL and virtual hosts at http://httpd.apache.org/docs/2.0/ssl....html#parallel and http://httpd.apache.org/docs/2.0/ssl...aq.html#vhosts
 
Old 05-25-2007, 01:11 AM   #3
p_s_shah
Member
 
Registered: Mar 2005
Location: India
Distribution: RHEL 3/4, Solaris 8/9/10, Fedora 4/8, Redhat Linux 9
Posts: 212
Blog Entries: 1

Rep: Reputation: 33
For running SSL sites you must have uniq IP for each SSL site.

Sample config for domain1.com [SSL & NonSSL] and domain2.com [NonSSL]

# For domain1.com Non-SSL requests
<VirtualHost 10.1.0.25:80>
Servername www.domain1.com
DocumentRoot /usr/local/apache2/htdocs/domain1/
</VirtualHost>

# For domain1.com SSL requests
<VirtualHost 10.1.0.25:443>
SSLEngine on
SSLCertificateFile "/usr/local/apache2/conf/server.crt"
SSLCertificateKeyFile "/usr/local/apache2/conf/server.key"
Servername www.domain1.com
DocumentRoot /usr/local/apache2/htdocs/domain1/
</VirtualHost>

# For domain2.com Non-SSL requests
<VirtualHost 10.1.0.26:80>
Servername www.domain2.com
DocumentRoot /usr/local/apache2/htdocs/domain1/
</VirtualHost>
 
Old 05-25-2007, 05:43 AM   #4
neocontrol
Member
 
Registered: Jul 2005
Posts: 271

Original Poster
Rep: Reputation: 31
Thanks for the links and the replies. So here is another linux question that may be better suited for a differnt forum. But I'll try it here first.

Since I need 2 IP's now, to run two differnt sites. How do I go about setting this up? Do I need two nic's now? I do already have 2 nics, but one is setup for external use. Or can this be fixed via a configuration setup?

Also, we do have extra external IP addresses, but they all get nat'd and get pumped to a local address. Would I use the external address or the internal address for the virtual host setup?

The machines use a 192.168..... addresss. We use 75...... addresses for our external.
 
Old 05-25-2007, 08:37 AM   #5
JimBass
Senior Member
 
Registered: Oct 2003
Location: New York City
Distribution: Debian Sid 2.6.32
Posts: 2,099

Rep: Reputation: 47
You don't need separate NICs for each IP, although that is a possibility. Linux is happy to assign up to 255 addresses per NIC, and that is how I would do it. For 2 SSL sites, assign 2 addresses in the 192.168 range you use on your LAN to this machine. Say for example you give the machine both 192.168.1.50 and 192.168.1.51. Make sure you assign just one gateway to the two virtual interfaces, something like this:

Code:
auto eth0
iface eth0 inet static
        address 192.168.1.50
        netmask 255.255.255.0
        network 192.168.1.0
        broadcast 192.168.1.255
        gateway 192.168.1.1

auto eth0:1
iface eth0:1 inet static
        address 192.168.1.51
        netmask 255.255.255.0
That is from a Debian /etc/networking/interfaces file, but I believe that syntax will work on all distros, it is just a question of where that file is. In any case, that gives the box both 192.168.1.50 and 192.168.1.51 on one NIC.

Then on your firewall or router, use port forwarding or one to one NAT to map 75.A.B.C to 192.168.1.50 and 75.A.B.D to 192.168.1.51. Then you change your apache to do the virtual hosts by addresses rather than names. The post above by p_s_shaw has that mapped out clearly, and you'd simply have to add the location of the second ssl config for that site. You'd use internal addresses on the apache host, and map the external addresses to those local through your gateway/firewall/router.

Peace,
JimBass
 
Old 05-25-2007, 09:33 AM   #6
neocontrol
Member
 
Registered: Jul 2005
Posts: 271

Original Poster
Rep: Reputation: 31
Ah yes. I have totally forgotten about that. Many thanks to everyone.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
need help with apach virtual hosts ssl/non ssl sites danthach Linux - Networking 3 05-25-2006 06:40 AM
apache-ssl setup virtual hosts notolerance Linux - Software 3 12-22-2005 04:20 PM
Apache + SSL + Virtual Hosts otisthegbs Linux - Software 3 10-05-2004 07:59 PM
Mulltiple SSL Virtual Hosts w/Apache jrbush82 Linux - Software 3 04-12-2004 02:49 PM
Apache2, SSL, 2 Virtual Hosts franticbob Linux - Software 0 04-07-2004 09:48 PM


All times are GMT -5. The time now is 05:36 AM.

Main Menu
 
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration