Apache domain best practice??
Apache domain best practice??
am 23.10.2007 01:53:49 von trpost
I have an apache 2.0.54 webserver that I want to setup to handle 10
small domains. In the past I have setup each domain to listen on port
80, but burned a virtual ip in doing so. If possible I want to move
away from assigning a virtual ip to each new domain. I tried setting
up each domain using the same ip, but a different port i.e. 80, 8080,
8081, etc, however am having trouble with users then having to access
the URL with the port i.e. www.testabc.com:8081
What is the best way or best practice when setting up an apache
webserver to handle multiple domains,
Thanks!
Re: Apache domain best practice??
am 23.10.2007 02:10:31 von shimmyshack
trp...@gmail.com wrote:
> I have an apache 2.0.54 webserver that I want to setup to handle 10
> small domains. In the past I have setup each domain to listen on port
> 80, but burned a virtual ip in doing so. If possible I want to move
> away from assigning a virtual ip to each new domain. I tried setting
> up each domain using the same ip, but a different port i.e. 80, 8080,
> 8081, etc, however am having trouble with users then having to access
> the URL with the port i.e. www.testabc.com:8081
>
> What is the best way or best practice when setting up an apache
> webserver to handle multiple domains,
>
> Thanks!
use a single IP!!
this is virtualhosting
set you apache to listen on port 80
then HTTP/1.1 (what every modern user agent uses) sends a host header
host: www.bbc.co.uk
in the request, this is passed to apache which therefore knows what
the browser is looking for, and you set rules in virtualhost stanzas
that tell apache where each host is
the first virtualhost stanza is always used when no other host header
matches any other virtualhost block so it tends to make sense to have
the first virtualhost a generic one
see apache docs under virtualhosting
DocumentRoot /var/www/generic_not_found/public
DocumentRoot /var/www/example.com/public
ServerName www.example.com
ServerAlias example.com
#etc...
Re: Apache domain best practice??
am 23.10.2007 02:21:52 von trpost
On Oct 22, 6:10 pm, shimmyshack wrote:
> trp...@gmail.com wrote:
> > I have an apache 2.0.54 webserver that I want to setup to handle 10
> > small domains. In the past I have setup each domain to listen on port
> > 80, but burned a virtual ip in doing so. If possible I want to move
> > away from assigning a virtual ip to each new domain. I tried setting
> > up each domain using the same ip, but a different port i.e. 80, 8080,
> > 8081, etc, however am having trouble with users then having to access
> > the URL with the port i.e.www.testabc.com:8081
>
> > What is the best way or best practice when setting up an apache
> > webserver to handle multiple domains,
>
> > Thanks!
>
> use a single IP!!
> this is virtualhosting
>
> set you apache to listen on port 80
>
> then HTTP/1.1 (what every modern user agent uses) sends a host header
>
> host:www.bbc.co.uk
>
> in the request, this is passed to apache which therefore knows what
> the browser is looking for, and you set rules in virtualhost stanzas
> that tell apache where each host is
>
> the first virtualhost stanza is always used when no other host header
> matches any other virtualhost block so it tends to make sense to have
> the first virtualhost a generic one
>
> see apache docs under virtualhosting
>
>
> DocumentRoot /var/www/generic_not_found/public
>
>
>
> DocumentRoot /var/www/example.com/public
> ServerNamewww.example.com
> ServerAlias example.com
>
>
> #etc...
Thanks for the quick response... Just to make sure I understand, would
this work for example:
DocumentRoot /var/www/generic_not_found/public
DocumentRoot /var/www/example.com/public
ServerName www.example.com
ServerAlias example.com
DocumentRoot /var/www/test.com/public
ServerName www.test.com
ServerAlias test.com
DocumentRoot /var/www/project.com/public
ServerName www.project.com
ServerAlias project.com
....
So in the above I am listening on port 80 and 1 ip address, but
handling 3 different domains based on the ServerName in the
VirtualHost definition. I guess I was thrown off a bit because what I
gathered in the docs was that I could use the same ip, but only for
subdomains, where here I actually have different domains.
Re: Apache domain best practice??
am 23.10.2007 13:27:40 von shimmyshack
On Oct 23, 1:21 am, trp...@gmail.com wrote:
> On Oct 22, 6:10 pm, shimmyshack wrote:
>
>
>
>
>
> > trp...@gmail.com wrote:
> > > I have an apache 2.0.54 webserver that I want to setup to handle 10
> > > small domains. In the past I have setup each domain to listen on port
> > > 80, but burned a virtual ip in doing so. If possible I want to move
> > > away from assigning a virtual ip to each new domain. I tried setting
> > > up each domain using the same ip, but a different port i.e. 80, 8080,
> > > 8081, etc, however am having trouble with users then having to access
> > > the URL with the port i.e.www.testabc.com:8081
>
> > > What is the best way or best practice when setting up an apache
> > > webserver to handle multiple domains,
>
> > > Thanks!
>
> > use a single IP!!
> > this is virtualhosting
>
> > set you apache to listen on port 80
>
> > then HTTP/1.1 (what every modern user agent uses) sends a host header
>
> > host:www.bbc.co.uk
>
> > in the request, this is passed to apache which therefore knows what
> > the browser is looking for, and you set rules in virtualhost stanzas
> > that tell apache where each host is
>
> > the first virtualhost stanza is always used when no other host header
> > matches any other virtualhost block so it tends to make sense to have
> > the first virtualhost a generic one
>
> > see apache docs under virtualhosting
>
> >
> > DocumentRoot /var/www/generic_not_found/public
> >
>
> >
> > DocumentRoot /var/www/example.com/public
> > ServerNamewww.example.com
> > ServerAlias example.com
> >
>
> > #etc...
>
> Thanks for the quick response... Just to make sure I understand, would
> this work for example:
>
>
> DocumentRoot /var/www/generic_not_found/public
>
>
>
> DocumentRoot /var/www/example.com/public
> ServerNamewww.example.com
> ServerAlias example.com
>
>
>
> DocumentRoot /var/www/test.com/public
> ServerNamewww.test.com
> ServerAlias test.com
>
>
>
> DocumentRoot /var/www/project.com/public
> ServerNamewww.project.com
> ServerAlias project.com
>
>
> ...
>
> So in the above I am listening on port 80 and 1 ip address, but
> handling 3 different domains based on the ServerName in the
> VirtualHost definition. I guess I was thrown off a bit because what I
> gathered in the docs was that I could use the same ip, but only for
> subdomains, where here I actually have different domains.- Hide quoted text -
>
> - Show quoted text -
yup it sure would, with the caveat that you have to tell apache that
its now in namevirtualhost mode. (you can keep the ip aliasing the way
you had it) because apache listens on all ip addresses if you dont
specify less (*:80) means listen on port 80 on all IPs, so
will work with your existing setup.
NameVirtualHost *:80
#or NameVirtualHost *
#or NameVirtualHost 10.10.10.12:80 ....
#depending on what you need.
DocumentRoot /var/www/generic_not_found/public
DocumentRoot /var/www/example.com/public
ServerName www.example.com
ServerAlias example.com
DocumentRoot /var/www/test.com/public
ServerName www.test.com
ServerAlias test.com
DocumentRoot /var/www/project.com/public
ServerName www.project.com
ServerAlias project.com
--------------------------
because you will probably only be using port 80 you could use this as
well:
DocumentRoot /var/www/generic_not_found/public
or even
DocumentRoot /var/www/generic_not_found/public
see its easy.
you can now try on the command line
telnet your_server_ ip 80
then copy this to the clipboard and simply paste in the command line
and press enter twice
GET / HTTP/1.1
host: www.project.com
or
GET / HTTP/1.1
host: project.com
you will be served the default index from the www.project.com/
project.com site,
or
GET / HTTP/1.1
host: 127.0.0.1
will not match any, so it will served from the first vhost stanza,
which is why having a catch all is useful - in case people use an OLD
or user agent not compliant with HTTP/1.1 or miss off the host header
in code you could consider writing
"you must use an HTTP/1.1 sompliant user agent to view content on this
server" mesage for the catch all vhost
you can also use more advanced mass virtual hosting, which requires
only that you create the file system structure, for the new host to
work, its therefore called dynamic mass virtual hosting.
http://httpd.apache.org/docs/2.2/mod/mod_vhost_alias.html
Re: Apache domain best practice??
am 30.10.2007 17:12:25 von trpost
On Oct 23, 5:27 am, shimmyshack wrote:
> On Oct 23, 1:21 am, trp...@gmail.com wrote:
>
>
>
>
>
> > On Oct 22, 6:10 pm, shimmyshack wrote:
>
> > > trp...@gmail.com wrote:
> > > > I have an apache 2.0.54 webserver that I want to setup to handle 10
> > > > small domains. In the past I have setup each domain to listen on port
> > > > 80, but burned a virtual ip in doing so. If possible I want to move
> > > > away from assigning a virtual ip to each new domain. I tried setting
> > > > up each domain using the same ip, but a different port i.e. 80, 8080,
> > > > 8081, etc, however am having trouble with users then having to access
> > > > the URL with the port i.e.www.testabc.com:8081
>
> > > > What is the best way or best practice when setting up an apache
> > > > webserver to handle multiple domains,
>
> > > > Thanks!
>
> > > use a single IP!!
> > > this is virtualhosting
>
> > > set you apache to listen on port 80
>
> > > then HTTP/1.1 (what every modern user agent uses) sends a host header
>
> > > host:www.bbc.co.uk
>
> > > in the request, this is passed to apache which therefore knows what
> > > the browser is looking for, and you set rules in virtualhost stanzas
> > > that tell apache where each host is
>
> > > the first virtualhost stanza is always used when no other host header
> > > matches any other virtualhost block so it tends to make sense to have
> > > the first virtualhost a generic one
>
> > > see apache docs under virtualhosting
>
> > >
> > > DocumentRoot /var/www/generic_not_found/public
> > >
>
> > >
> > > DocumentRoot /var/www/example.com/public
> > > ServerNamewww.example.com
> > > ServerAlias example.com
> > >
>
> > > #etc...
>
> > Thanks for the quick response... Just to make sure I understand, would
> > this work for example:
>
> >
> > DocumentRoot /var/www/generic_not_found/public
> >
>
> >
> > DocumentRoot /var/www/example.com/public
> > ServerNamewww.example.com
> > ServerAlias example.com
> >
>
> >
> > DocumentRoot /var/www/test.com/public
> > ServerNamewww.test.com
> > ServerAlias test.com
> >
>
> >
> > DocumentRoot /var/www/project.com/public
> > ServerNamewww.project.com
> > ServerAlias project.com
> >
>
> > ...
>
> > So in the above I am listening on port 80 and 1 ip address, but
> > handling 3 different domains based on the ServerName in the
> > VirtualHost definition. I guess I was thrown off a bit because what I
> > gathered in the docs was that I could use the same ip, but only for
> > subdomains, where here I actually have different domains.- Hide quoted text -
>
> > - Show quoted text -
>
> yup it sure would, with the caveat that you have to tell apache that
> its now in namevirtualhost mode. (you can keep the ip aliasing the way
> you had it) because apache listens on all ip addresses if you dont
> specify less (*:80) means listen on port 80 on all IPs, so
> will work with your existing setup.
>
> NameVirtualHost *:80
> #or NameVirtualHost *
> #or NameVirtualHost 10.10.10.12:80 ....
> #depending on what you need.
>
>
> DocumentRoot /var/www/generic_not_found/public
>
>
>
> DocumentRoot /var/www/example.com/public
> ServerNamewww.example.com
> ServerAlias example.com
>
>
>
> DocumentRoot /var/www/test.com/public
> ServerNamewww.test.com
> ServerAlias test.com
>
>
>
> DocumentRoot /var/www/project.com/public
> ServerNamewww.project.com
> ServerAlias project.com
>
>
> --------------------------
> because you will probably only be using port 80 you could use this as
> well:
>
> DocumentRoot /var/www/generic_not_found/public
>
> or even
>
> DocumentRoot /var/www/generic_not_found/public
>
>
> see its easy.
>
> you can now try on the command line
> telnet your_server_ ip 80
>
> then copy this to the clipboard and simply paste in the command line
> and press enter twice
>
> GET / HTTP/1.1
> host:www.project.com
>
> or
>
> GET / HTTP/1.1
> host: project.com
>
> you will be served the default index from thewww.project.com/
> project.com site,
>
> or
>
> GET / HTTP/1.1
> host: 127.0.0.1
>
> will not match any, so it will served from the first vhost stanza,
> which is why having a catch all is useful - in case people use an OLD
> or user agent not compliant with HTTP/1.1 or miss off the host header
> in code you could consider writing
> "you must use an HTTP/1.1 sompliant user agent to view content on this
> server" mesage for the catch all vhost
>
> you can also use more advanced mass virtual hosting, which requires
> only that you create the file system structure, for the new host to
> work, its therefore called dynamic mass virtual hosting.http://httpd.apache.org/docs/2.2/mod/mod_vhost_alias .html- Hide quoted text -
>
> - Show quoted text -
So I got this to work fine for port 80, however read that port 443 SSL
does not work well with named virtual hosts. What is the best practice
in this case?
Re: Apache domain best practice??
am 01.11.2007 16:00:26 von shimmyshack
On Oct 30, 4:12 pm, trp...@gmail.com wrote:
> On Oct 23, 5:27 am, shimmyshack wrote:
>
>
>
>
>
> > On Oct 23, 1:21 am, trp...@gmail.com wrote:
>
> > > On Oct 22, 6:10 pm, shimmyshack wrote:
>
> > > > trp...@gmail.com wrote:
> > > > > I have an apache 2.0.54 webserver that I want to setup to handle 10
> > > > > small domains. In the past I have setup each domain to listen on port
> > > > > 80, but burned a virtual ip in doing so. If possible I want to move
> > > > > away from assigning a virtual ip to each new domain. I tried setting
> > > > > up each domain using the same ip, but a different port i.e. 80, 8080,
> > > > > 8081, etc, however am having trouble with users then having to access
> > > > > the URL with the port i.e.www.testabc.com:8081
>
> > > > > What is the best way or best practice when setting up an apache
> > > > > webserver to handle multiple domains,
>
> > > > > Thanks!
>
> > > > use a single IP!!
> > > > this is virtualhosting
>
> > > > set you apache to listen on port 80
>
> > > > then HTTP/1.1 (what every modern user agent uses) sends a host header
>
> > > > host:www.bbc.co.uk
>
> > > > in the request, this is passed to apache which therefore knows what
> > > > the browser is looking for, and you set rules in virtualhost stanzas
> > > > that tell apache where each host is
>
> > > > the first virtualhost stanza is always used when no other host header
> > > > matches any other virtualhost block so it tends to make sense to have
> > > > the first virtualhost a generic one
>
> > > > see apache docs under virtualhosting
>
> > > >
> > > > DocumentRoot /var/www/generic_not_found/public
> > > >
>
> > > >
> > > > DocumentRoot /var/www/example.com/public
> > > > ServerNamewww.example.com
> > > > ServerAlias example.com
> > > >
>
> > > > #etc...
>
> > > Thanks for the quick response... Just to make sure I understand, would
> > > this work for example:
>
> > >
> > > DocumentRoot /var/www/generic_not_found/public
> > >
>
> > >
> > > DocumentRoot /var/www/example.com/public
> > > ServerNamewww.example.com
> > > ServerAlias example.com
> > >
>
> > >
> > > DocumentRoot /var/www/test.com/public
> > > ServerNamewww.test.com
> > > ServerAlias test.com
> > >
>
> > >
> > > DocumentRoot /var/www/project.com/public
> > > ServerNamewww.project.com
> > > ServerAlias project.com
> > >
>
> > > ...
>
> > > So in the above I am listening on port 80 and 1 ip address, but
> > > handling 3 different domains based on the ServerName in the
> > > VirtualHost definition. I guess I was thrown off a bit because what I
> > > gathered in the docs was that I could use the same ip, but only for
> > > subdomains, where here I actually have different domains.- Hide quoted text -
>
> > > - Show quoted text -
>
> > yup it sure would, with the caveat that you have to tell apache that
> > its now in namevirtualhost mode. (you can keep the ip aliasing the way
> > you had it) because apache listens on all ip addresses if you dont
> > specify less (*:80) means listen on port 80 on all IPs, so
> > will work with your existing setup.
>
> > NameVirtualHost *:80
> > #or NameVirtualHost *
> > #or NameVirtualHost 10.10.10.12:80 ....
> > #depending on what you need.
>
> >
> > DocumentRoot /var/www/generic_not_found/public
> >
>
> >
> > DocumentRoot /var/www/example.com/public
> > ServerNamewww.example.com
> > ServerAlias example.com
> >
>
> >
> > DocumentRoot /var/www/test.com/public
> > ServerNamewww.test.com
> > ServerAlias test.com
> >
>
> >
> > DocumentRoot /var/www/project.com/public
> > ServerNamewww.project.com
> > ServerAlias project.com
> >
>
> > --------------------------
> > because you will probably only be using port 80 you could use this as
> > well:
> >
> > DocumentRoot /var/www/generic_not_found/public
> >
> > or even
> >
> > DocumentRoot /var/www/generic_not_found/public
> >
>
> > see its easy.
>
> > you can now try on the command line
> > telnet your_server_ ip 80
>
> > then copy this to the clipboard and simply paste in the command line
> > and press enter twice
>
> > GET / HTTP/1.1
> > host:www.project.com
>
> > or
>
> > GET / HTTP/1.1
> > host: project.com
>
> > you will be served the default index from thewww.project.com/
> > project.com site,
>
> > or
>
> > GET / HTTP/1.1
> > host: 127.0.0.1
>
> > will not match any, so it will served from the first vhost stanza,
> > which is why having a catch all is useful - in case people use an OLD
> > or user agent not compliant with HTTP/1.1 or miss off the host header
> > in code you could consider writing
> > "you must use an HTTP/1.1 sompliant user agent to view content on this
> > server" mesage for the catch all vhost
>
> > you can also use more advanced mass virtual hosting, which requires
> > only that you create the file system structure, for the new host to
> > work, its therefore called dynamic mass virtual hosting.http://httpd.apache.org/docs/2.2/mod/mod_vhost_alias .html-Hide quoted text -
>
> > - Show quoted text -
>
> So I got this to work fine for port 80, however read that port 443 SSL
> does not work well with named virtual hosts. What is the best practice
> in this case?- Hide quoted text -
>
> - Show quoted text -
well you can create a signature for multiple hosts using cacert.org