[Cialug] Virtual hosts in Apache

Tim Wilson tim_linux at wilson-home.com
Fri Jun 1 22:52:31 CDT 2007


I figured out why foobar.domain1.com was always displaying the page for
foo.domain1.com when going to port 80.  From the Apache website: "If no
matching virtual host is found, then *the first listed virtual host* that
matches the IP address will be used."  So I moved my entry with the invalid
DocumentRoot to the top, and now it works.  I'm still getting a couple "no
VirtualHosts" warnings.  Both are for domain2, which is a .us domain.  There
isn't anything weird with a .us domain, is there?

On 6/1/07, Tim Wilson <tim_linux at wilson-home.com> wrote:
>
> It looks like I have it working, what I did was in addition to the entry
> for foobar.domain1.com on port 8080, I added the following:
> <VirtualHost 127.0.0.1:80>
>     ServerName foobar.domain1.com
>     DocumentRoot /var/www/foobar
> </VirtualHost>
>
> Where /var/www/foobar doesn't exist.  That way, if someone goes to
> foobar.domain1.com on port 80, they'll get a 404.  Until today, I was only
> listening on 8080, keeping people from finding I had a web server running
> (since most only scan port 80).  However, I have some legit people accessing
> certain sites, but some where having problems going to 8080.
>
> The one problem is if someone goes to the actual IP address, they're still
> presented with the foo.domain1.com page instead of an error.  I'll see if
> there's a way to do a redirect or rewrite.
>
> On 6/1/07, Barry Von Ahsen <barry at vonahsen.com> wrote:
> >
> > Tim Wilson wrote:
> > > On 6/1/07, Chris Freeman <cwfreeman at gmail.com> wrote:
> > >>
> > >>
> > >>
> > >> On 6/1/07, David Champion < dchampion at visionary.com> wrote:
> > >> >
> > >> > ...
> > >> > Doing a search / replace on the IP isn't that hard (at least using
> > joe.
> > >> > Doing it in vi, well, that's another story).
> > >> >
> > >> > -dc
> > >>
> > >>
> > >> <off-topic flame="on" why="because I can" >
> > >> While doing it in joe might not be hard, doing it in vi is downright
> > >> easy.
> > >> And fun. ;-)
> > >> </off-topic>
> > >>
> > >>
> > >>
> > >> _______________________________________________
> > >> Cialug mailing list
> > >> Cialug at cialug.org
> > >> http://cialug.org/mailman/listinfo/cialug
> > >>
> > >>
> > > Ignoring the potential flame war (FTR, I use emacs, and it is very
> > easy), I
> > > tried it with IP addresses and with *.  With *, I get warnings when
> > > restarting httpd.  With IP addresses (or with *), If I go to
> > > foobar.domain1.com (port 80), I get what I would expect from
> > > foo.domain1.com.
> > > Is there a way to display an error when someone goes to
> > > foobar.domain1.comon port 80, but display the page when they go to
> > > port 8080?  I did add
> > > NameVirtualHost lines with the appropriate ports.
> > >
> >
> > you could do
> > <VirtualHost foobarip:80>
> >         ServerName foobar.domain1.com
> >         Redirect / http://foobar.domain1.com:8080/
> > </VirtualHost>
> >
> > to redirect them or
> >
> >         RedirectMatch permanent (.*) http://foobar.domain1.com:8080$1
> >
> > to redirect them to what they requested
> >
> > -barry
> > _______________________________________________
> > Cialug mailing list
> > Cialug at cialug.org
> > http://cialug.org/mailman/listinfo/cialug
> >
>
>
>
> --
> Tim




-- 
Tim
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://cialug.org/pipermail/cialug/attachments/20070601/2be6fbf3/attachment.htm


More information about the Cialug mailing list