You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Gusti Benawi <Be...@gmx.de> on 2003/10/03 10:50:47 UTC

[users@httpd] VirtualHost help

Hi Folks,

Suppose i have static ip-address, mydomain.com
and i would like to make many subdomains a.mydomain.com , b.mydomain.com
and  each a.mydomain.com or b.mydomain.com will be taken to directory a or b
inside my htdocs.

can it be done with VirtualHost?
i have done these my httpd.conf

NameVirtualHost *:80

<VirtualHost _default_:*>
    DocumentRoot /usr/web/www/htdocs
    ErrorLog /usr/web/log/virtual-server-error-log
    CustomLog /usr/web/log/virtual-server-access-log combined
</VirtualHost>

<VirtualHost *>
    ServerAdmin me@mydomain.com
    DocumentRoot /usr/web/www/htdocs/a
    ServerName a.mydomain.com
    ErrorLog /usr/web/log/virtual-server-error-log
    CustomLog /usr/web/log/virtual-server-access-log combined
</VirtualHost>

<VirtualHost *>
    ServerAdmin me@mydomain.com
    DocumentRoot /usr/web/www/htdocs/b
    ServerName b.mydomain.com
    ErrorLog /usr/web/log/virtual-server-error-log
    CustomLog /usr/web/log/virtual-server-access-log combined
</VirtualHost>


i restarted apache, apache worked
 but when i type a.mydomain.com or b.mydomain.com 

it won't work 

-- 
NEU FÜR ALLE - GMX MediaCenter - für Fotos, Musik, Dateien...
Fotoalbum, File Sharing, MMS, Multimedia-Gruß, GMX FotoService

Jetzt kostenlos anmelden unter http://www.gmx.net

+++ GMX - die erste Adresse für Mail, Message, More! +++



-- 
NEU FÜR ALLE - GMX MediaCenter - für Fotos, Musik, Dateien...
Fotoalbum, File Sharing, MMS, Multimedia-Gruß, GMX FotoService

Jetzt kostenlos anmelden unter http://www.gmx.net

+++ GMX - die erste Adresse für Mail, Message, More! +++


---------------------------------------------------------------------
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] VirtualHost help

Posted by Leif W <wa...@usa.net>.
Hello,

Only thing I can see is to change all the VirtualHost to *:80 to match the
NameVirtualHost directive.  Other than that, it looks ok.  In what way isn't
it working?  Can you be more specific?  Is a different page showing up than
what you expected?  Is no page showing up at all?  Is there anything in the
access log?  In the error log?

I notice you have all the logfiles for each VirtualHost pointing to the same
file, and using the combined log format.  Are you making sure to include the
ServerName in the log with %v or %V ( see
http://httpd.apache.org/docs-2.0/mod/mod_log_config.html ), otherwise, you
won't know which site traffic is coming from, and it could also make it hard
to troubleshoot.  Alternately, you could put each VirtualHost logfile into a
separate log (if you haven't got thousands).  Usually the only reason to
combine them is if you have too many VirtualHosts (several thousand), and
the OS can't open all those files at once (or eg. while doing logrotation).

Leif

----- Original Message ----- 
From: "Gusti Benawi" <Be...@gmx.de>
To: <us...@httpd.apache.org>
Sent: Friday, October 03, 2003 4:50 AM
Subject: [users@httpd] VirtualHost help


> Hi Folks,
>
> Suppose i have static ip-address, mydomain.com
> and i would like to make many subdomains a.mydomain.com , b.mydomain.com
> and  each a.mydomain.com or b.mydomain.com will be taken to directory a or
b
> inside my htdocs.
>
> can it be done with VirtualHost?
> i have done these my httpd.conf
>
> NameVirtualHost *:80
>
> <VirtualHost _default_:*>
>     DocumentRoot /usr/web/www/htdocs
>     ErrorLog /usr/web/log/virtual-server-error-log
>     CustomLog /usr/web/log/virtual-server-access-log combined
> </VirtualHost>
>
> <VirtualHost *>
>     ServerAdmin me@mydomain.com
>     DocumentRoot /usr/web/www/htdocs/a
>     ServerName a.mydomain.com
>     ErrorLog /usr/web/log/virtual-server-error-log
>     CustomLog /usr/web/log/virtual-server-access-log combined
> </VirtualHost>
>
> <VirtualHost *>
>     ServerAdmin me@mydomain.com
>     DocumentRoot /usr/web/www/htdocs/b
>     ServerName b.mydomain.com
>     ErrorLog /usr/web/log/virtual-server-error-log
>     CustomLog /usr/web/log/virtual-server-access-log combined
> </VirtualHost>
>
>
> i restarted apache, apache worked
>  but when i type a.mydomain.com or b.mydomain.com
>
> it won't work
>
> -- 
> NEU FÜR ALLE - GMX MediaCenter - für Fotos, Musik, Dateien...
> Fotoalbum, File Sharing, MMS, Multimedia-Gruß, GMX FotoService
>
> Jetzt kostenlos anmelden unter http://www.gmx.net
>
> +++ GMX - die erste Adresse für Mail, Message, More! +++
>
>
>
> -- 
> NEU FÜR ALLE - GMX MediaCenter - für Fotos, Musik, Dateien...
> Fotoalbum, File Sharing, MMS, Multimedia-Gruß, GMX FotoService
>
> Jetzt kostenlos anmelden unter http://www.gmx.net
>
> +++ GMX - die erste Adresse für Mail, Message, More! +++
>
>
> ---------------------------------------------------------------------
> 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] VirtualHost help

Posted by Leif W <wa...@usa.net>.
----- Original Message ----- 
From: "Gusti Benawi" <Be...@gmx.de>
To: <us...@httpd.apache.org>
Sent: Friday, October 03, 2003 1:52 PM
Subject: Re: [users@httpd] VirtualHost help


> > > On Fri, Oct 03, 2003 at 04:38:55PM +0200, Jonas Eckerman wrote:
> > > > > i restarted apache, apache worked ut when i type a.mydomain.com or
> > > > > b.mydomain.com
> > > > Of course you also updated you DNS pointers so that a.mydomain.com
and
> > > b.mydomain.com pointed the the web server?
> > > How do i do that?
> > Ahh, this helps.  :)  Is mydomain.com a registered name on the internet
> > and
> > you have gone to the registrar's website and logged in and specified
> > primary
> > and secondary DNS servers?
> yes, mydomain.com is a registered name on the internet,
> i have also specified the primary and secondary DNS servers.
>
> > If yes, then you have to have A or CNAME records added such that the new
> > host names a.mydomain.com, b.mydomain.com, c.mydomain.com, etc., are all
> > going to resolve to the IP address of your webserver.
> what is A or CNAME records?
>
> how can i do that, that a.mydomain.com, b.mydomqin.com etc., are all going
> to resolve to the IP address of my webserver?
>
> is it done by the sysadmin?

Yes, the sysadmin for the primary (and secondary) dns servers listed (same
person likely).  You'll need to ask for an A (address) record to point
a.myname.myuni.edu to your IP (and often a PTR record to point the IP back
to your hostname, but this is mostly important only for reverse lookups, for
mailservers).  They may say no.  It's their IPs, their domain and their DNS,
so it's their call.  Some unis may be more flexible than others.  Some may
have strict policies to prevent a flood of customary DNS requests coming in
each semester, and then only to have to flush them out every semester.

It's usually a good idea to keep the DNS with the people who own the IPs
that your server uses, so you can be sure to get the PTR if you need mail
servicves (only the people who own the IP can create the PTR for it).  But
if you were to register your own domain on the internet, you could use some
outside party for your DNS servers (someone mentioned http://zoneedit.com/
on the list this week), and point them back to your IP.  You won't get the
PTR record but it's not critical if you're just learning for a few test
sites.

Leif

> i was given only one static-ip which belong to the uni.
> for example the uni's address is myuni.edu , then i was given an ip, which
> dns myname.myuni.edu.
> thats all, now i installed webserver on linux box, setting up the ip,
> gateway, host, primary and secondary dns server.
>
> what i would like is only to make a.myname.myuni.edu possible
>



---------------------------------------------------------------------
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] VirtualHost help

Posted by Jonas Eckerman <jo...@frukt.org>.
On Fri, 3 Oct 2003 19:52:15 +0200 (MEST), Gusti Benawi wrote:

Please, find a FAQ on IP adresses, domain names and DNS.

> how can i do that, that a.mydomain.com, b.mydomqin.com etc., are
> all going to resolve to the IP address of my webserver?

> is it done by the sysadmin?

It is done by whoever administers the name servers resposible for mydomain.com. Wether that person also administers anything else is impossible for us to know.

If you don't know who that is, ask whatever tech support you can contact to tell you who to speak with.

/Jonas

-- 
Jonas Eckerman, jonas_lists@frukt.org
http://www.fsdb.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] VirtualHost help

Posted by Gusti Benawi <Be...@gmx.de>.
> > On Fri, Oct 03, 2003 at 04:38:55PM +0200, Jonas Eckerman wrote:
> > > > i restarted apache, apache worked ut when i type a.mydomain.com or
> > > > b.mydomain.com
> > > Of course you also updated you DNS pointers so that a.mydomain.com and
> > b.mydomain.com pointed the the web server?
> > How do i do that?
> Ahh, this helps.  :)  Is mydomain.com a registered name on the internet
> and
> you have gone to the registrar's website and logged in and specified
> primary
> and secondary DNS servers?
yes, mydomain.com is a registered name on the internet,
i have also specified the primary and secondary DNS servers.

> If yes, then you have to have A or CNAME records added such that the new
> host names a.mydomain.com, b.mydomain.com, c.mydomain.com, etc., are all
> going to resolve to the IP address of your webserver.
what is A or CNAME records?

how can i do that, that a.mydomain.com, b.mydomqin.com etc., are all going
to resolve to the IP address of my webserver?

is it done by the sysadmin?
i was given only one static-ip which belong to the uni.
for example the uni's address is myuni.edu , then i was given an ip, which
dns myname.myuni.edu.
thats all, now i installed webserver on linux box, setting up the ip,
gateway, host, primary and secondary dns server. 

what i would like is only to make a.myname.myuni.edu possible

-- 
--
He abused me, he beated me,
He defeated me, he robbed me,
In those who harbour such thoughts
Hatred never ceases.

NEU FÜR ALLE - GMX MediaCenter - für Fotos, Musik, Dateien...
Fotoalbum, File Sharing, MMS, Multimedia-Gruß, GMX FotoService

Jetzt kostenlos anmelden unter http://www.gmx.net

+++ GMX - die erste Adresse für Mail, Message, More! +++


---------------------------------------------------------------------
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] VirtualHost help

Posted by Leif W <wa...@usa.net>.
----- Original Message ----- 
From: "Gusti Benawi" <Be...@gmx.de>
To: <us...@httpd.apache.org>
Sent: Friday, October 03, 2003 12:54 PM
Subject: Re: [users@httpd] VirtualHost help


> Hi,
> Thanx for replying
>
> On Fri, Oct 03, 2003 at 04:38:55PM +0200, Jonas Eckerman wrote:
> > > i restarted apache, apache worked ut when i type a.mydomain.com or
> > > b.mydomain.com
> > Of course you also updated you DNS pointers so that a.mydomain.com and
> b.mydomain.com pointed the the web server?
> How do i do that?

Ahh, this helps.  :)  Is mydomain.com a registered name on the internet and
you have gone to the registrar's website and logged in and specified primary
and secondary DNS servers?

If yes, then you have to have A or CNAME records added such that the new
host names a.mydomain.com, b.mydomain.com, c.mydomain.com, etc., are all
going to resolve to the IP address of your webserver.

If no, (i.e. mydomain.com exists only in you /etc/hosts file or
C:\WINNT\System32\drivers\etc\hosts), then you can just add those names to
the hosts file of the client machine (where you surf with the browser).  You
could do it either way, (i.e. to get your config working while you wait for
the DNS changes to take effect, or if you only want to do in-house testing),
but it will only work on that computer, not for other computers.

Example hosts file:

127.0.0.1    localhost
192.168.1.100    mydomain.com
192.168.1.100    a.mydomain.com
192.168.1.100    b.mydomain.com
1.2.3.4                c.mydomain.com

Leif

> > > it won't work
> > In what way doesn't it work?
> > The browser can't resolve the domain name?
> in that way, but it worked with mydomain.com
>
> > The computer explodes?
> =)
>
> On Fri, Oct 03, 2003 at 09:18:53AM -0400, Leif W wrote:
> > Is there anything in the
> > access log?  In the error log?
> no log, because the browser cn't resolve the domain name
>
> > I notice you have all the logfiles for each VirtualHost pointing to the
> same
> > file, and using the combined log format.  Are you making sure to include
> the
> > ServerName in the log with %v or %V
> i use the default LogFormat
>
> LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\""
> combined
> LogFormat "%h %l %u %t \"%r\" %>s %b" common
> LogFormat "%{Referer}i -> %U" referer
> LogFormat "%{User-agent}i" agent
>
> > Alternately, you could put each VirtualHost logfile into a
> > separate log (if you haven't got thousands).
> sure, you are quite right
>
> yours
>
> -- 
> --
> He abused me, he beated me,
> He defeated me, he robbed me,
> In those who harbour such thoughts
> Hatred never ceases.
>
> NEU FÜR ALLE - GMX MediaCenter - für Fotos, Musik, Dateien...
> Fotoalbum, File Sharing, MMS, Multimedia-Gruß, GMX FotoService
>
> Jetzt kostenlos anmelden unter http://www.gmx.net
>
> +++ GMX - die erste Adresse für Mail, Message, More! +++
>
>
> ---------------------------------------------------------------------
> 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] VirtualHost help

Posted by Jonas Eckerman <jo...@frukt.org>.
On Fri, 3 Oct 2003 18:54:54 +0200 (MEST), Gusti Benawi wrote:

> > Of course you also updated you DNS pointers so that
> a.mydomain.com and b.mydomain.com pointed the the web server?

Yes. The browser must somehow know wich IP adress to connect to. If it doesn't know that, it can't connect.

> How do i do that?

If you have you're own DNS, edit the zone file. If you don't run the DNS yourself, contact whoever does that. Anyway, this really has nothing to do with Apache.

Just for testing the setup, you can add a.mydomain.com and b.mydomain.com to the hosts file on the machine your running the browser on. The exact location of the file depends on your operating system.

> > The browser can't resolve the domain name?
> in that way, but it worked with mydomain.com
[...]
> no log, because the browser cn't resolve the domain name

Then it's pretty obvious that it isn't an Apache problem. If the browser never even contacts the web server, then how could the web server answer correctly?

The fact that it worked with mydomain.com is probably because there's a DNS record pointing the domain name mydomain.com to the IP of your web server.

Regards
/Jonas

-- 
Jonas Eckerman, jonas_lists@frukt.org
http://www.fsdb.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] VirtualHost help

Posted by Gusti Benawi <Be...@gmx.de>.
Hi,
Thanx for replying
  
On Fri, Oct 03, 2003 at 04:38:55PM +0200, Jonas Eckerman wrote:
> > i restarted apache, apache worked ut when i type a.mydomain.com or
> > b.mydomain.com
> Of course you also updated you DNS pointers so that a.mydomain.com and
b.mydomain.com pointed the the web server?
How do i do that?

> > it won't work
> In what way doesn't it work?
> The browser can't resolve the domain name?
in that way, but it worked with mydomain.com

> The computer explodes?
=)

On Fri, Oct 03, 2003 at 09:18:53AM -0400, Leif W wrote:
> Is there anything in the
> access log?  In the error log?
no log, because the browser cn't resolve the domain name

> I notice you have all the logfiles for each VirtualHost pointing to the
same
> file, and using the combined log format.  Are you making sure to include
the
> ServerName in the log with %v or %V
i use the default LogFormat

LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\""
combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent

> Alternately, you could put each VirtualHost logfile into a
> separate log (if you haven't got thousands).
sure, you are quite right

yours

-- 
--
He abused me, he beated me,
He defeated me, he robbed me,
In those who harbour such thoughts
Hatred never ceases.

NEU FÜR ALLE - GMX MediaCenter - für Fotos, Musik, Dateien...
Fotoalbum, File Sharing, MMS, Multimedia-Gruß, GMX FotoService

Jetzt kostenlos anmelden unter http://www.gmx.net

+++ GMX - die erste Adresse für Mail, Message, More! +++


---------------------------------------------------------------------
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] VirtualHost help

Posted by Jonas Eckerman <jo...@frukt.org>.
On Fri, 3 Oct 2003 10:50:47 +0200 (MEST), Gusti Benawi wrote:
> i restarted apache, apache worked ut when i type a.mydomain.com or
> b.mydomain.com


Of course you also updated you DNS pointers so that a.mydomain.com and b.mydomain.com pointed the the web server?

> it won't work

In what way doesn't it work?

The browser can't resolve the domain name?
Apache won't answer?
Apache doesn't server the correct pages?
Apache returns an error?
The computer explodes?

Regards
/Jonas
-- 
Jonas Eckerman, jonas_lists@frukt.org
http://www.fsdb.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