Printable Version of Topic

Click here to view this topic in its original format

Linuxhelp _ Tips and Tricks _ Multiple Vhosts Behind A Router

Posted by: Corey May 31 2004, 08:31 AM

I'm not sure if anyone else has ever had a problem with this, but I did, so i expect that someone else out there might run into it at some point.

My network setup includes a linksys router connected directly to the internet using a pppoe internet connection. I have a dynamic IP and thanks to hughsjr's scripts (see http://www.linuxhelp.ca/forums/index.php?act=ST&f=7&t=3527) my ip is constantly updated with my domain.

On my router, I have port 80 being forwarded from the router to my internet webserver (192.168.0.2).

Currently I have www.thegoodtimes.ca and sober.thegoodtimes.ca setup, using apache 1.3.x, here is my virtual host settings at the bottom of my /etc/apache/httpd.conf file:

QUOTE
NameVirtualHost *:80

<VirtualHost *>
  ServerName www.thegoodtimes.ca
  ServerAlias thegoodtimes.ca
  DocumentRoot /var/www
</VirtualHost>
<VirtualHost *>
  ServerName sober.thegoodtimes.ca
  DocumentRoot /home/blew/public_html
</VirtualHost>


Obviously I can add more options to the VirtualHost directives, but using this bare minimum made it work.

Posted by: hughesjr May 31 2004, 01:54 PM

Corey ...

If you want to keep seperate stats for each site, then you will probably want customlogs for each site.

Here is what I did with logs in my VirtualHost

CODE
<VirtualHost *:80>
   ServerName www.hughesjr.com
   ServerAlias hughesjr.com
   DocumentRoot /var/www/hughesjr.com
   ErrorLog logs/hughesjr.com-error_log
   CustomLog logs/hughesjr.com-access_log combined
   <Directory "/var/www/hughesjr.com">
      Options Indexes FollowSymLinks
      AllowOverride All
      Order allow,deny
      Allow from all
   </Directory>
</VirtualHost>


Then I run http://www.analog.cx/ seperately on each set of log files.

Another thing aboutlog stats is you probably want to use the combined log type and not the common log type ... if combined is defined in your /etc/httpd.conf file ... for me it is:

CODE
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


and I use CustomLog path_to_file combined
########################################################

I also edited the scripts in http://www.linuxhelp.ca/forums/index.php?act=ST&f=7&t=3527#entry13404 to have both an option for an external router ... or if you are running on a linux router.

Posted by: Corey Jun 1 2004, 07:28 AM

Yeah, I knew you could have custom log files, which I do have setup, but I just wanted to post the bare minimum for getting the multiple vhosts working correctly.

Those scripts you wrote are really helpfull and are working perfectly for me smile.gif Thanks.

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)