LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (http://www.linuxquestions.org/questions/linux-networking-3/)
-   -   apache virtualhost (http://www.linuxquestions.org/questions/linux-networking-3/apache-virtualhost-25835/)

jonfa 07-15-2002 08:29 PM

apache virtualhost
 
Hi All,

I have a Redhat 7.2 box with a DSL connection. The ISP dynamically assigns the IP's so the IP changes often. Right now I use DTDNS.com for DNS service to run my website (http://redhatjon.slyip.net). This runs flawlessly, but I want to set up several other websites on the same box, but I am unsure of the parameters required by httpd.conf. Will something like the following work:

NameVirtualHost redhatjon.slyip.net
<VirtualHost 192.168.0.7> # 192.168.0.7 is the IP of the Redhat box with apache running
ServerName redhatjon.slyip.net
DocumentRoot "/var/www/html"
</VirtualHost>

NameVirtualHost someother.slyip.net
<VirtualHost 192.168.0.7>
ServerName someother.slyip.net
DocumentRoot "/var/www/html/someother"
</VirtualHost>

I already have redhatjon.slyip.net specified in the beginning of httpd.conf so does this even need to be in the VirtualHost section? What am I doing wrong? Is this even possible?

--
Jon Faranda

te_conway 07-16-2002 08:10 AM

Yes, this will work provided you setup the domain aliases with your dns service

Rashkae 07-16-2002 03:49 PM

192.168.*.* is an internal address, unless you you have a firewall port forwading port 80 to your Http Server, people will be unable to accesss your web server from over the internet.

Try this:

NameVirtualhost *

<virtualhost *>
Directives...
</virtualhost>

repeast as needed.

That should configure Apache to use all your active IP addresses as as Name based virtual hosts.

Syncrm 07-18-2002 11:31 AM

i have a similar configuration in terms of domains and apache. however, i have never been able to get virtual hosts working correctly.

my network setup is as follows: my domain name is endrium.com, which uses the DNS servers of mydomain.com to point to my IP. however, my cable company blocks port 80, which means that www.endrium.com is forwarded to web.endrium.com:81 from mydomain.com. this is necessary since all requests to port 80 are blocked.

i'm running a firewall with IP MASQ and iptables which forwards all port 81 requests to the machine which apache is residing on. my virtual hosts appear as follows:

NameVirtualHost *

<VirtualHost *>
ServerName web.endrium.com
ServerAdmin root@endrium.com
DocumentRoot /usr/local/apache/htdocs
ErrorLog logs/error_log
CustomLog logs/access_log custom
</VirtualHost>

<VirtualHost 192.168.1.56>
DocumentRoot /usr/local/apache/htdocs
ServerAdmin root@toby.endrium.com
ServerName toby.endrium.com
ErrorLog logs/internal/error_log
CustomLog logs/internal/access_log custom
</VirtualHost>

the weird thing is that the second virtual host works perfectly (as it keeps separate log files for my internal clients. but if i change the first VH to some non-existant docroot, nothing happens and everything goes to the default docroot.

does anyone have any suggestions at all? i've been pulling my hair out over this for some time now and am still unable to find a solution. :-(

turnip 07-18-2002 03:50 PM

Ready?

here is the easiest way to do v-hosts
setup one docroot, nuke the v-host entry out of httpd.conf
make your new v-host a sub dir in doc root

then in doc root make a .htaccess file

RewriteEngine on
Options +FollowSymlinks
RewriteBase /
RewriteCond %{HTTP_HOST} www.yourvhost.com
RewriteCond %{REQUEST_URI} !path/to/dir/
RewriteRule ^(.*)$ path/to/dir/$1 [L]

put one site in doc root, the other in path/to/dir and you're good to go.

xylum 08-12-2002 06:07 PM

after i modify my vhost file is there a change i need to make in the http.conf file? ot get vhost to work?


All times are GMT -5. The time now is 11:30 PM.