LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
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
  Search this Thread
Old 07-04-2008, 11:33 AM   #1
Madone_SL_5.5
Member
 
Registered: Oct 2006
Location: Ogden, Utah
Distribution: Fedora 10
Posts: 66

Rep: Reputation: 15
setting up virtual hosts


I'm new to virtual hosting, and also to ssl. I have both up and running tolerably well on my web server running Fedora 9, but have run into a couple of questions.

First, as you can see from the quote bellow, I have one site (firsthost.org) that is partly open and partly ssl. The open portion reads from the directory I have specified (/var/www/html/firsthost/), but the ssl portion bases itself from the /var/www/html/ directory even though I have specified /var/www/html/firsthost/ssl/ as its home directory. It doesn't care about the home directory specification. Why is this?

Second, is it acceptable for me to resolve both www.firsthost.org and firsthost.org by using the wildcard *.firsthost.org as in the first specified virtual host? Is there a better way? It does seem to work just fine.

The end of my httpd.conf file is as follows:


Quote:
NameVirtualHost *:80
#
# NOTE: NameVirtualHost cannot be used without a port specifier
# (e.g. :80) if mod_ssl is being used, due to the nature of the
# SSL protocol.
#

#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for requests without a known
# server name.
#
#<VirtualHost *:80>
# ServerAdmin webmaster@dummy-host.example.com
# DocumentRoot /www/docs/dummy-host.example.com
# ServerName dummy-host.example.com
# ErrorLog logs/dummy-host.example.com-error_log
# CustomLog logs/dummy-host.example.com-access_log common
#</VirtualHost>

<VirtualHost *:80>
ServerName *.firsthost.org
DocumentRoot /var/www/html/firsthost/
</VirtualHost>

<VirtualHost *:80>
ServerName www.secondhost.com
DocumentRoot /var/www/html/secondhost/
</VirtualHost>

<IfDefine SSL>
<VirtualHost _default_:443>
ServerName *.firsthost.org
DocumentRoot /var/www/html/firsthost/ssl/
SSLEngine on
SSLCertificateFile /etc/httpd/conf/ssl.crt
SSLCertificateKeyFile /etc/httpd/conf/ssl.key
</VirtualHost>
</IfDefine>
Thanks for any suggestions.
 
Old 07-04-2008, 03:45 PM   #2
harry edwards
Member
 
Registered: Nov 2007
Location: Lincolnshire, UK
Distribution: CentOS, Fedora, and Suse
Posts: 365

Rep: Reputation: 48
Have you tried explicitly stating the hosts as a named virtual host? In my experience it reads better and works:

Code:
# IP of server
NameVirtualHost 1.2.3.4 # Change this


<VirtualHost 1.2.3.4:80>
ServerName www.firsthost.org
DocumentRoot /var/www/html/firsthost/
</VirtualHost>

<VirtualHost 1.2.3.4:80>
ServerName www.secondhost.com
DocumentRoot /var/www/html/secondhost/
</VirtualHost>

<VirtualHost 1.2.3.4:443>
ServerName www.firsthost.org
DocumentRoot /var/www/html/firsthost/ssl/
SSLEngine on
SSLCertificateFile /etc/httpd/conf/ssl.crt
SSLCertificateKeyFile /etc/httpd/conf/ssl.key
</VirtualHost>
This URL cover the topic quite well http://httpd.apache.org/docs/1.3/vhosts/examples.html
 
Old 07-05-2008, 08:12 AM   #3
vovaNux
LQ Newbie
 
Registered: Jul 2008
Posts: 6

Rep: Reputation: 0
Try also this link: http://www.lampdocs.com/blog/2008/04...st-that-works/
 
Old 07-05-2008, 02:29 PM   #4
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Ubuntu 12.04, Antix19.3
Posts: 3,794

Rep: Reputation: 282Reputation: 282Reputation: 282
Apache determines the virtual host based on the url that it receives. However, when you use ssl, that is encrypted and apache can not determine which host is requested. That is why you need to use ip-based virtual hosting and not name-based virtual hosting for the ssl site.

So my solution would be the same as in post 2, but only an ip-address for the ssl based site.
 
Old 07-05-2008, 04:19 PM   #5
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 63
Or you can redirect to a different port, where you run a single SSL host.
 
  


Reply



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



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Setting Up Subversion And Trac As Virtual Hosts On An Ubuntu Server LXer Syndicated Linux News 0 01-13-2008 09:20 AM
vsftpd, web uploads, vsftpd virtual users, apache virtual hosts, home directories jerryasher Linux - Software 7 02-18-2007 06:29 AM
Problems setting up virtual hosts with debian sarge and apache2 dthacker Debian 1 11-23-2005 05:25 PM
About setting up virtual hosts raymond Linux - General 7 09-21-2004 09:14 AM
Setting up virtual hosts in Apache using Webmin Spudley Linux - Software 2 09-25-2003 08:50 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 06:20 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration