?
Solved

Apache Virtual Hosting

Posted on 2003-03-18
7
Medium Priority
?
261 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

 

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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
The viewer will learn how to dynamically set the form action using jQuery.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Suggested Courses

764 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