?
Solved

Apache Virtual Hosting

Posted on 2003-03-18
7
Medium Priority
?
267 Views
Last Modified: 2013-11-18
I'm having issues hosting some internal websites on a Slackware 8.1, Apache 1.3.27, PHP 4.3.0 server.

--------------------------------------------------------------
NameVirtualHost *

<VirtualHost *>
     ServerAdmin webmaster@cpio.co.uk
     DocumentRoot /home/intranet/public_html/
     DirectoryIndex index.php index.shtml index.html
</VirtualHost>

<VirtualHost *>
     ServerName admin.apps.cpio.co.uk
     ServerAdmin webmaster@cpio.co.uk
     DocumentRoot /home/intranet/public_html_admin/
     DirectoryIndex index.php index.shtml index.html
     <Location /server-status>
          SetHandler server-status
          Order deny,allow
          Deny from all
          Allow from .cpio.co.uk
     </Location>
</VirtualHost>

<VirtualHost *>
     ServerName intranet.apps.cpio.co.uk
     ServerAdmin webmaster@cpio.co.uk
     DocumentRoot /home/intranet/public_html_old/htdocs
     DirectoryIndex index.php index.shtml index.html
     ScriptAlias /cgi-bin /home/intranet/public_html_old/cgi-bin
     <Directory /home/intranet/public_html_old/htdocs>
          Options Includes ExecCGI
          Order deny,allow
          Deny from All
          Allow from 168.43. 10.1.251. 10.1.250.
          AuthUserFile ./.htpasswd
          AuthName "CPiO Limited Intranet"
          AuthType Basic
          Require valid-user
          Satisfy any
     </Directory>
     <Directory /home/intranet/public_html_old/cgi-bin>
          AllowOverride All
          Options Includes ExecCGI
          Order allow,deny
          Allow from all
     </Directory>
     <Directory "/home/intranet/public_html_old/cgi-bin/admin/">
          Options +Includes +Indexes +ExecCGI
          AuthUserFile /home/intranet/public_html_old/cgi-bin/admin/.htpasswd
          AuthName "CPiO Limited Intranet"
          AuthType Basic
          Satisfy All
          Require valid-user
     </Directory>
     Alias /icons /home/intranet/public_html_old/icons
     Alias /images /home/intranet/public_html_old/images
     Alias /templates /home/intranet/public_html_old/templates
</VirtualHost>
--------------------------------------------------------------

The only one I can connect to is http://admin.apps.cpio.co.uk, connecting to intranet.apps.cpio.co.uk gives me a 403, as does connecting to the ip address. I want it to refuse connection to just the ip address but not to the other virtual hosts. Can anyone help me, please?

There is actually a 3rd subdomain to add to this server but once I get these 2, and the basic(default/ip) one working right then I'm sure I can do the 3rd one just fine.
0
Comment
Question by:Narusegawa
  • 3
  • 3
7 Comments
 
LVL 51

Assisted Solution

by:ahoffmann
ahoffmann earned 225 total points
ID: 8159173
several reasons possible:
  1. you don't have the virtual hosts in your DNS
  2. your client does not send a correct Host in the HTTP header (HTTP/1.1)
in both cases apache uses the first virtual server as default
0
 

Author Comment

by:Narusegawa
ID: 8159239
I have all the domains in /etc/hosts

And my clients are IE6 and Mozilla 1.3, which as I'm aware of both are sending them. I added a test.apps.cpio.co.uk, using the same values are the intranet.apps.cpio.co.uk virtual host and that works fine. It's just intranet.apps.cpio.co.uk that doesn't. I know the machine itself is called intranet, if I look at /etc/HOSTNAME I see intranet.apps.cpio.co.uk in it.
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 8159397
check what the browser sends as Host in the HTTP header, probably it uses admin which is the CNAME of intranet (am I right here with CNAME?).
0
Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

 

Author Comment

by:Narusegawa
ID: 8159670
As a random guess I changed what was in /etc/HOSTNAME to 850r.apps.cpio.co.uk instead of intranet.apps.cpio.co.uk, rebooted the server and it all works.

However I know this is now fixed I still don't understand as to why /etc/HOSTNAME file affected the virtual host in Apache.
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 8159779
not shure too what apache does with these virtual hosts, you may try to add the IP or the intranet.apps.cpio.co.uk in the <VirtualHost > instead of the *
Think that the problem appears if you do not have a clean DNS and/or a mixture of DNS and /etc/hosts.
0
 
LVL 2

Accepted Solution

by:
ChrisDrake earned 225 total points
ID: 8162535
This works for me - just point the first entry to something without read access if you want to return "Denied" messages:-


NameVirtualHost 203.63.235.5:80

# This first entry will be where people arrive if no server name was supplied

DocumentRoot /var/www/html

<VirtualHost 203.63.235.5:80>
  ServerName 203.63.235.5
  ServerPath /203
  DocumentRoot /var/www/html/203
  ServerAdmin Root@203.63.235.5
</VirtualHost>

# These are the virtual hosts:-

<VirtualHost 203.63.235.5:80>
  ServerName foo.com
  ServerPath /foo
  DocumentRoot /var/www/html/foo
  ServerAlias Foo.com *.foo.com
  ServerAdmin pr@foo.com
</VirtualHost>

etc...

0
 

Author Comment

by:Narusegawa
ID: 8571603
It turned out that if I changed the hostname of the machine then it worked. I had our system admin change a few DNS reverse records and it worked. Thanks for all the answers though.
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
Suggested Courses

579 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question