CentOS 5/ Apache2 and Virtual hosts

Support for webhosts that use CentOS
Post Reply
metallica1973
Posts: 17
Joined: 2007/12/27 11:33:00

CentOS 5/ Apache2 and Virtual hosts

Post by metallica1973 » 2008/08/10 18:34:25

I have setup CentOS 5, Apache, and am trying to host several website via vhosts. I am using one static ip address and vhosts to allow access to all multiple website on this server. I have the web server on the DMZ, created a rule using IPTABLES to allow access to the web server on the DMZ via tcp 80. I have also done this as well on the web server to allow access to tcp port 80. I have changed the DNS entry on my domain registrar to point to my static ip address at the office. It is not working and I am trying to figure this out and need help from the Gurus.

I place my web pages in /var/www/html/Test.com/

[PHP]

ls -l /var/www/html/test.com/
Images/ Test.com.html Test_Under_Construction.html
[/PHP]

here is my /etc/httpd

[PHP]NameVirtualHost 192.168.2.24:80


ServerAdmin test@yahoo.com
DocumentRoot /var/www/html/Test.com/
ServerName Test.com
# ErrorLog logs/dummy-host.example.com-error_log
# CustomLog logs/dummy-host.example.com-access_log common



ServerAdmin test2@yahoo.com
DocumentRoot /var/www/html/Test2.com/
ServerName Test2.com
# ErrorLog logs/dummy-host.example.com-error_log
# CustomLog logs/dummy-host.example.com-access_log common

[/PHP]

My iptable rules on the External Firewall\Proxy.

[PHP]$IPTABLES -A FORWARD -p tcp -i $EXTIF -o $DMZ_IFACE -d $DMZ_WEB_SERVER --dport 80 -m state --state NEW -j ACCEPT
$IPTABLES -t nat -A PREROUTING -p tcp -i $EXTIF --dport 80 -j DNAT --to-destination $DMZ_WEB_SERVER
[/PHP]

On the web server itself I have 80 allowed through the firewall.

[PHP] 1 44 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:80[/PHP]

the Apache access log:

[PHP]127.0.0.1 - - [10/Aug/2008:01:05:26 -0400] "GET / HTTP/1.1" 403 5043 "-" "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.1) Gecko/2008071616 CentOS/3.0.1-1.el5.centos Firefox/3.0.1"
127.0.0.1 - - [10/Aug/2008:01:05:26 -0400] "GET /icons/apache_pb.gif HTTP/1.1" 200 2326 "http://localhost/" "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.1) Gecko/2008071616 CentOS/3.0.1-1.el5.centos Firefox/3.0.1"
127.0.0.1 - - [10/Aug/2008:01:05:26 -0400] "GET /icons/powered_by_rh.png HTTP/1.1" 200 1213 "http://localhost/" "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.1) Gecko/2008071616 CentOS/3.0.1-1.el5.centos Firefox/3.0.1"
127.0.0.1 - - [10/Aug/2008:01:05:27 -0400] "GET /favicon.ico HTTP/1.1" 404 283 "-" "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.1) Gecko/2008071616 CentOS/3.0.1-1.el5.centos Firefox/3.0.1"
127.0.0.1 - - [10/Aug/2008:01:05:30 -0400] "GET /favicon.ico HTTP/1.1" 404 283 "-" "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.1) Gecko/2008071616 CentOS/3.0.1-1.el5.centos Firefox/3.0.1[/PHP]

I know that the Domain registrar is pointing to the correct public address. I changed the A record to point to our public addess.

[PHP] nslookup test.com
Server: 4.2.2.5
Address: 4.2.2.5#53

Non-authoritative answer:
Name: test.com
Address: XX.XXX.XX.XX
[/PHP]


Could my proxy being the cause of the issue. This is the only rule that I have on my firewall in regards to the proxy and it is a redirection rule tell all of my client traffic to go through the proxy transparently.
[PHP]$IPTABLES -t nat -A PREROUTING -i $INTIF -p tcp -d ! $SQUID_BOX --dport 80 -j REDIRECT --to-ports $DG_PORT
[/PHP]

What am I doing wrong?

kentyler
Posts: 161
Joined: 2007/06/20 13:31:05
Location: Northeast Ohio
Contact:

CentOS 5/ Apache2 and Virtual hosts

Post by kentyler » 2008/08/12 19:04:59

You mostly have it right, the only problem is that you are not using any wildcards for matching.

Take a look at the docs for this it's kinda easy to understand.

http://httpd.apache.org/docs/2.2/vhosts/name-based.html


NameVirtualHost *:80


ServerName www.domain.tld
ServerAlias domain.tld *.domain.tld
DocumentRoot /www/domain



ServerName www.otherdomain.tld
DocumentRoot /www/otherdomain

Post Reply

Return to “CentOS 5 - Webhosting Support”