You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Stephen Colson <sc...@westpole.com> on 2003/01/31 07:07:59 UTC

[users@httpd] Name based virtual hosts

Greetings,

I've been trying to get apache to do name based virtual hosting for two 
dev url's I have, but apache doesn't seem to be wanting to deal with my 
httpd.conf entry for the second domain.

The error: "#apachectl restart
Shutting down Web Service: httpd
Setting up Web Service: [Fri Jan 31 00:38:21 2003] [warn] 
NameVirtualHost 127.0.0.1:80 has no VirtualHosts
/usr/sbin/httpd"

  Below is the entries in my config file--mind you the IP and domain 
names have been changed, but are properly routable/look-upable. It's a 
Raq3 running Apache 1.3.6, however this is Sun's release of Apache for 
Cobal-linux systems and has all of their patches.

Are there any glaring errors? Thoughts? Suggestions? Blank stares and 
general laughter is also accepted.

Thanks!
-s


__begin conf entries__
#...
NameVirtualHost 127.0.0.1
<VirtualHost dev.domain1.org www.dev.domain1.org>
ServerName dev.domain1.org
ServerAdmin admin
DocumentRoot /home/sites/site4/web
ServerAlias www.dev.domain1.org
RewriteEngine on
RewriteCond %{HTTP_HOST}                !^127.0.0.1(:80)?$
RewriteCond %{HTTP_HOST}                !^www.dev.domain1.org(:80)?$
RewriteRule ^/(.*)                      http://www.dev.domain1.org/$1 
[L,R]
RewriteCond %{HTTP_HOST}                !^dev.domain1.org(:80)?$
RewriteRule ^/(.*)                      http://dev.domain1.org/$1 [L,R]
RewriteOptions inherit
AliasMatch ^/~([^/]+)(/(.*))? /home/sites/site4/users/$1/web/$3
AliasMatch ^/users/([^/]+)(/(.*))? /home/sites/site4/users/$1/web/$3
AddHandler cgi-wrapper .cgi
AddHandler cgi-wrapper .pl
TransferLog /home/sites/www.dev.domain1.org/logs/access_log
ErrorLog /home/sites/www.dev.domain1.org/logs/error_log
#LogFormat "%{User-agent}i -> %U" agent
#CustomLog /home/sites/www.domain1.org/logs/agent_log agent
</VirtualHost>


NameVirtualHost 127.0.0.1
<VirtualHost dev.domain2.org www.dev.domain2.org>
ServerName dev.domain2.org
ServerAdmin admin
DocumentRoot /home/sites/site5/web
ServerAlias www.dev.domain2.org
RewriteEngine on
RewriteCond %{HTTP_HOST}                !^127.0.0.1(:80)?$
RewriteCond %{HTTP_HOST}                !^www.dev.domain2.org(:80)?$
RewriteRule ^/(.*)                      http://www.dev.domain2.org/$1 
[L,R]
RewriteCond %{HTTP_HOST}                !^dev.domain2.org(:80)?$
RewriteRule ^/(.*)                      http://dev.domain2.org/$1 [L,R]
RewriteOptions inherit
AliasMatch ^/~([^/]+)(/(.*))? /home/sites/site5/users/$1/web/$3
AliasMatch ^/users/([^/]+)(/(.*))? /home/sites/site5/users/$1/web/$3
AddHandler cgi-wrapper .cgi
AddHandler cgi-wrapper .pl
TransferLog /home/sites/www.dev.domain2.org/logs/access_log
ErrorLog /home/sites/www.dev.domain2.org/logs/error_log
#LogFormat "%{User-agent}i -> %U" agent
#CustomLog /home/sites/www.domain2.org/logs/agent_log agent
</VirtualHost>
__end conf entries__


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Name based virtual hosts

Posted by Stephen Colson <sc...@westpole.com>.
On Friday, Jan 31, 2003, at 10:42 America/Detroit, Joshua Slive wrote:
> 1. You need only a single NameVirtualHost directive for each IP, not 
> one
> for each <VirtualHost>.
This fixed the problem, thanks!

> 2. Unless you are doing something complicated (SSL, mixed IP/name based
> vhosts), you should use "*" in place of the IP address in 
> NameVirtualHost
> and <VirtualHost> as suggested by the docs.
Yes. There are a bunch of other domain names and IP's on that box. 
domain1 and domain2 should only listen to the specified IP, or I would 
have wildcarded it.

> 3. You RewriteRules make no sense.  What are they supposed to do?
Artifact of the Cobalt web control panel. To be honest, I don't know 
what they do either, but it seems to work with the rewrite's in there, 
so I don't really mind it much.

Thanks all for your help!
-s


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Name based virtual hosts

Posted by Joshua Slive <jo...@slive.ca>.
On Fri, 31 Jan 2003, Stephen Colson wrote:

> Tried it again after reading that, got the same error:
> "# apachectl restart
> Shutting down Web Service: httpd
> Setting up Web Service: [Fri Jan 31 10:22:14 2003] [warn]
> NameVirtualHost 69.0.x.x:80 has no VirtualHosts
> /usr/sbin/httpd"

1. You need only a single NameVirtualHost directive for each IP, not one
for each <VirtualHost>.

2. Unless you are doing something complicated (SSL, mixed IP/name based
vhosts), you should use "*" in place of the IP address in NameVirtualHost
and <VirtualHost> as suggested by the docs.

3. You RewriteRules make no sense.  What are they supposed to do?

Joshua.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Name based virtual hosts

Posted by Stephen Colson <sc...@westpole.com>.
Tried it again after reading that, got the same error:
"# apachectl restart
Shutting down Web Service: httpd
Setting up Web Service: [Fri Jan 31 10:22:14 2003] [warn] 
NameVirtualHost 69.0.x.x:80 has no VirtualHosts
/usr/sbin/httpd"

I've changed the IP in this example so that we can get off of that 
whole loopback issue, but it has stayed the same in the actual config 
file (the IP here, but with the x's filled in properly).

Having done a line by line comparison of these two virtual host blocks 
(the top one works, and has worked), the only difference is domain1 vs 
domain2. Further ideas? New config below.

Thanks,
-s


On Friday, Jan 31, 2003, at 10:01 America/Detroit, Joshua Slive wrote:

>
> On Fri, 31 Jan 2003, Stephen Colson wrote:
>> I've been trying to get apache to do name based virtual hosting for 
>> two
>> dev url's I have, but apache doesn't seem to be wanting to deal with 
>> my
>> httpd.conf entry for the second domain.
>
> There are several different things wrong with your configuration.  But
> perhaps the best advice I can give you is to carefully read:
> http://httpd.apache.org/docs/vhosts/name-based.html
>
> If you make your configuration look like the same one there, and it 
> still
> doesn't work, then come back for more help.
>
> Joshua.

__begin conf block__
NameVirtualHost 69.0.x.x
<VirtualHost 69.0.x.x>
ServerName dev.domain1.org
ServerAdmin admin
DocumentRoot /home/sites/site4/web
ServerAlias dev.domain1.org www.dev.domain1.org
RewriteEngine on
RewriteCond %{HTTP_HOST}                !^69.0.x.x(:80)?$
RewriteCond %{HTTP_HOST}                !^www.dev.domain1.org(:80)?$
RewriteRule ^/(.*)                      http://www.dev.domain1.org/$1 
[L,R]
RewriteCond %{HTTP_HOST}                !^dev.domain1.org(:80)?$
RewriteRule ^/(.*)                      http://dev.domain1.org/$1 [L,R]
RewriteOptions inherit
AliasMatch ^/~([^/]+)(/(.*))? /home/sites/site4/users/$1/web/$3
AliasMatch ^/users/([^/]+)(/(.*))? /home/sites/site4/users/$1/web/$3
AddHandler cgi-wrapper .cgi
AddHandler cgi-wrapper .pl
TransferLog /home/sites/www.dev.domain1.org/logs/access_log
ErrorLog /home/sites/www.dev.domain1.org/logs/error_log
#LogFormat "%{User-agent}i -> %U" agent
#CustomLog /home/sites/www.domain1.org/logs/agent_log agent
</VirtualHost>


NameVirtualHost 69.0.x.x
<VirtualHost 69.0.x.x>
ServerName dev.domain2.org
ServerAdmin admin
DocumentRoot /home/sites/site5/web
ServerAlias dev.domain2.org www.dev.domain2.org
RewriteEngine on
RewriteCond %{HTTP_HOST}                !^69.0.x.x(:80)?$
RewriteCond %{HTTP_HOST}                !^www.dev.domain2.org(:80)?$
RewriteRule ^/(.*)                      http://www.dev.domain2.org/$1 
[L,R]
RewriteCond %{HTTP_HOST}                !^dev.domain2.org(:80)?$
RewriteRule ^/(.*)                      http://dev.domain2.org/$1 [L,R]
RewriteOptions inherit
AliasMatch ^/~([^/]+)(/(.*))? /home/sites/site5/users/$1/web/$3
AliasMatch ^/users/([^/]+)(/(.*))? /home/sites/site5/users/$1/web/$3
AddHandler cgi-wrapper .cgi
AddHandler cgi-wrapper .pl
TransferLog /home/sites/www.dev.domain2.org/logs/access_log
ErrorLog /home/sites/www.dev.domain2.org/logs/error_log
#LogFormat "%{User-agent}i -> %U" agent
#CustomLog /home/sites/www.domain2.org/logs/agent_log agent
</VirtualHost>
__end conf block__


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Name based virtual hosts

Posted by Joshua Slive <jo...@slive.ca>.
On Fri, 31 Jan 2003, Stephen Colson wrote:
> I've been trying to get apache to do name based virtual hosting for two
> dev url's I have, but apache doesn't seem to be wanting to deal with my
> httpd.conf entry for the second domain.

There are several different things wrong with your configuration.  But
perhaps the best advice I can give you is to carefully read:
http://httpd.apache.org/docs/vhosts/name-based.html

If you make your configuration look like the same one there, and it still
doesn't work, then come back for more help.

Joshua.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Name based virtual hosts

Posted by Jurgen <ap...@squarehosting.com>.
Hi,

well, this way the apache server will not respond to anything else, but local requests from the same server. You will have to have the hosts file or the DNS setup, so the domain names resolve to 127.0.0.1.
You could use then <VirtualHost 127.0.0.1> instead of using the domain names.

Jurgen


On Fri, 31 Jan 2003 01:31:32 -0500
Stephen Colson <sc...@westpole.com> wrote:

> I'm not actually using the loop back address. I'm just putting that in 
> there so as to protect the privacy of the server owner. The IP is real 
> and public routable, and the domain is an actual FQDN, but both were 
> changed in this email.
> 
> -s
> 
> On Friday, Jan 31, 2003, at 01:14 America/Detroit, Jeff Cohen wrote:
> 
> > You are using a loopback address (127.0.0.1) how do you expect it to 
> > work?
> > This address is valid only for the local computer, if you have more 
> > then one
> > IP address then try them one by one instead of 127.0.0.1.
> > If there's no security involved, change to be
> > NameVirtualHost *
> > And than change the 127.0.0.1 to the appropriate IPs you have inside 
> > the
> > Vhost directives.
> >
> > All the best,
> > Jeff Cohen
> 
> 
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP Server Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>    "   from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Name based virtual hosts

Posted by "J. Greenlees" <ja...@shaw.ca>.
hmm, private publicly available data... domain name /ip numbers are 
publicly available as they are not considered confidential data.

kind of like posting to a list like this, or a newsgroup, with a 
standard signature of private and confidential communication.

Stephen Colson wrote:
> I'm not actually using the loop back address. I'm just putting that in 
> there so as to protect the privacy of the server owner. The IP is real 
> and public routable, and the domain is an actual FQDN, but both were 
> changed in this email.
> 
> -s
> 
> On Friday, Jan 31, 2003, at 01:14 America/Detroit, Jeff Cohen wrote:
> 
>> You are using a loopback address (127.0.0.1) how do you expect it to 
>> work?
>> This address is valid only for the local computer, if you have more 
>> then one
>> IP address then try them one by one instead of 127.0.0.1.
>> If there's no security involved, change to be
>> NameVirtualHost *
>> And than change the 127.0.0.1 to the appropriate IPs you have inside the
>> Vhost directives.
>>
>> All the best,
>> Jeff Cohen



---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Name based virtual hosts

Posted by Stephen Colson <sc...@westpole.com>.
I'm not actually using the loop back address. I'm just putting that in 
there so as to protect the privacy of the server owner. The IP is real 
and public routable, and the domain is an actual FQDN, but both were 
changed in this email.

-s

On Friday, Jan 31, 2003, at 01:14 America/Detroit, Jeff Cohen wrote:

> You are using a loopback address (127.0.0.1) how do you expect it to 
> work?
> This address is valid only for the local computer, if you have more 
> then one
> IP address then try them one by one instead of 127.0.0.1.
> If there's no security involved, change to be
> NameVirtualHost *
> And than change the 127.0.0.1 to the appropriate IPs you have inside 
> the
> Vhost directives.
>
> All the best,
> Jeff Cohen


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


RE: [users@httpd] Name based virtual hosts

Posted by Jeff Cohen <ap...@gej-it.com>.
You are using a loopback address (127.0.0.1) how do you expect it to work?
This address is valid only for the local computer, if you have more then one
IP address then try them one by one instead of 127.0.0.1.
If there's no security involved, change to be 
NameVirtualHost *
And than change the 127.0.0.1 to the appropriate IPs you have inside the
Vhost directives.

All the best,
Jeff Cohen

> -----Original Message-----
> From: Stephen Colson [mailto:scolson@westpole.com]
> Sent: Friday, January 31, 2003 1:08 AM
> To: users@httpd.apache.org
> Subject: [users@httpd] Name based virtual hosts
> 
> Greetings,
> 
> I've been trying to get apache to do name based virtual hosting for two
> dev url's I have, but apache doesn't seem to be wanting to deal with my
> httpd.conf entry for the second domain.
> 
> The error: "#apachectl restart
> Shutting down Web Service: httpd
> Setting up Web Service: [Fri Jan 31 00:38:21 2003] [warn]
> NameVirtualHost 127.0.0.1:80 has no VirtualHosts
> /usr/sbin/httpd"
> 
>   Below is the entries in my config file--mind you the IP and domain
> names have been changed, but are properly routable/look-upable. It's a
> Raq3 running Apache 1.3.6, however this is Sun's release of Apache for
> Cobal-linux systems and has all of their patches.
> 
> Are there any glaring errors? Thoughts? Suggestions? Blank stares and
> general laughter is also accepted.
> 
> Thanks!
> -s
> 
> 
> __begin conf entries__
> #...
> NameVirtualHost 127.0.0.1
> <VirtualHost dev.domain1.org www.dev.domain1.org>
> ServerName dev.domain1.org
> ServerAdmin admin
> DocumentRoot /home/sites/site4/web
> ServerAlias www.dev.domain1.org
> RewriteEngine on
> RewriteCond %{HTTP_HOST}                !^127.0.0.1(:80)?$
> RewriteCond %{HTTP_HOST}                !^www.dev.domain1.org(:80)?$
> RewriteRule ^/(.*)                      http://www.dev.domain1.org/$1
> [L,R]
> RewriteCond %{HTTP_HOST}                !^dev.domain1.org(:80)?$
> RewriteRule ^/(.*)                      http://dev.domain1.org/$1 [L,R]
> RewriteOptions inherit
> AliasMatch ^/~([^/]+)(/(.*))? /home/sites/site4/users/$1/web/$3
> AliasMatch ^/users/([^/]+)(/(.*))? /home/sites/site4/users/$1/web/$3
> AddHandler cgi-wrapper .cgi
> AddHandler cgi-wrapper .pl
> TransferLog /home/sites/www.dev.domain1.org/logs/access_log
> ErrorLog /home/sites/www.dev.domain1.org/logs/error_log
> #LogFormat "%{User-agent}i -> %U" agent
> #CustomLog /home/sites/www.domain1.org/logs/agent_log agent
> </VirtualHost>
> 
> 
> NameVirtualHost 127.0.0.1
> <VirtualHost dev.domain2.org www.dev.domain2.org>
> ServerName dev.domain2.org
> ServerAdmin admin
> DocumentRoot /home/sites/site5/web
> ServerAlias www.dev.domain2.org
> RewriteEngine on
> RewriteCond %{HTTP_HOST}                !^127.0.0.1(:80)?$
> RewriteCond %{HTTP_HOST}                !^www.dev.domain2.org(:80)?$
> RewriteRule ^/(.*)                      http://www.dev.domain2.org/$1
> [L,R]
> RewriteCond %{HTTP_HOST}                !^dev.domain2.org(:80)?$
> RewriteRule ^/(.*)                      http://dev.domain2.org/$1 [L,R]
> RewriteOptions inherit
> AliasMatch ^/~([^/]+)(/(.*))? /home/sites/site5/users/$1/web/$3
> AliasMatch ^/users/([^/]+)(/(.*))? /home/sites/site5/users/$1/web/$3
> AddHandler cgi-wrapper .cgi
> AddHandler cgi-wrapper .pl
> TransferLog /home/sites/www.dev.domain2.org/logs/access_log
> ErrorLog /home/sites/www.dev.domain2.org/logs/error_log
> #LogFormat "%{User-agent}i -> %U" agent
> #CustomLog /home/sites/www.domain2.org/logs/agent_log agent
> </VirtualHost>
> __end conf entries__
> 
> 
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP Server Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>    "   from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org