LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices

Reply
 
Thread Tools
Old 02-08-2009, 03:43 PM   #1
cam34
Member
 
Registered: Aug 2003
Distribution: OpenSuse 11.1, SLES10, Fedora 11 & XP 4 Gaming *sniffs
Posts: 92
Thanked: 1
apache - mod_proxy to vhost two internal addresses


[Log in to get rid of this advertisement]
Hi People,

I needing some assistance with mod_proxy.

Scenario: We have two domains and one external IP address and our router NAT'ing.

I need to get apache2 to reverse proxy two internal websites based on which domain they request.

Port 80 is getting answered by 192.168.1.50 (apache) (also domain cam34.com)
This box should also reverse proxy tim.com to 192.168.1.100

Using this virtual host conf file - whenever I enter cam34.com or tim.com I always get tim.com

Hope that makes sense.

Code:
<VirtualHost *:80>
    ServerAdmin webmaster@dummy-host.example.com
    ServerName cam34.com

 
    DocumentRoot /srv/www/htdocs

    ErrorLog /var/log/apache2/cam-error_log
    CustomLog /var/log/apache2/cam-access_log combined

    # don't loose time with IP address lookups
    HostnameLookups Off

    # needed for named virtual hosts
    UseCanonicalName On

    # configures the footer on server-generated documents
    ServerSignature On
       # This should be changed to whatever you set DocumentRoot to.
    #
    <Directory "/srv/www/htdocs">
        Options Indexes FollowSymLinks
        AllowOverride None
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

<proxy>
          Order deny,allow

          Allow from all
</proxy>
ServerName tim.com
ProxyPass / http://192.168.1.100/
ProxyPassReverse / http://192.168.1.100/
cam34 is offline     Reply With Quote
Old 02-12-2009, 04:44 AM   #2
chitambira
Member
 
Registered: Oct 2008
Location: Fife
Distribution: RHEL, Centos
Posts: 363
Blog Entries: 1
Thanked: 37
The directive ServerName tim.com which is out side the vhost config takes precedence over any vhost that you have. Best setup is to make tim.com also a vhost, so that you will have proper apache vhost config for both cam34 and tim.
chitambira is offline     Reply With Quote
Old 02-12-2009, 11:32 PM   #3
cam34
Member
 
Registered: Aug 2003
Distribution: OpenSuse 11.1, SLES10, Fedora 11 & XP 4 Gaming *sniffs
Posts: 92
Thanked: 1

Original Poster
the problem im not hosting tim.com at all. im hosting cam34.com which lives on server 192.168.1.50 while tim.com lives on 192.168.1.100.
All though 192.168.1.50 is recieving port 80 from the external world.
cam34 is offline     Reply With Quote
Old 02-13-2009, 05:01 AM   #4
chitambira
Member
 
Registered: Oct 2008
Location: Fife
Distribution: RHEL, Centos
Posts: 363
Blog Entries: 1
Thanked: 37
I meant, put all that into a vhost config like this

Quote:
<VirtualHost *:80>
ServerAdmin webmaster@dummy-host.example.com
ServerName cam34.com

DocumentRoot /srv/www/htdocs

ErrorLog /var/log/apache2/cam-error_log
CustomLog /var/log/apache2/cam-access_log combined

# don't loose time with IP address lookups
HostnameLookups Off

# needed for named virtual hosts
UseCanonicalName On

# configures the footer on server-generated documents
ServerSignature On
# This should be changed to whatever you set DocumentRoot to.
#
<Directory "/srv/www/htdocs">
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
</VirtualHost>

<VirtualHost*:80>
ServerName tim.com
ProxyPass / http://192.168.1.100/
ProxyPassReverse / http://192.168.1.100/
ErrorLog logs/tim.com-error_log
CustomLog logs/tim.com-access_log combined
<proxy>
Order deny,allow
Allow from all
</proxy>
</VirtualHost>

Last edited by chitambira; 02-13-2009 at 05:04 AM..
chitambira is offline     Reply With Quote
Thanked by:
Old 02-19-2009, 12:15 AM   #5
cam34
Member
 
Registered: Aug 2003
Distribution: OpenSuse 11.1, SLES10, Fedora 11 & XP 4 Gaming *sniffs
Posts: 92
Thanked: 1

Original Poster
OMG! Thank you! I have been pulling my hair out trying to get this going!!!

here is my modified httpd.conf from OpenSuse 11.0 with the vhosts.d/ put it to httpd.conf so i could read whats happening!
THANKS AGAIN!!

Code:
Include /etc/apache2/uid.conf
Include /etc/apache2/server-tuning.conf
ErrorLog /var/log/apache2/error_log
Include /etc/apache2/sysconfig.d/loadmodule.conf
Include /etc/apache2/listen.conf
# predefined logging formats
Include /etc/apache2/mod_log_config.conf

# generated from global settings in /etc/sysconfig/apache2
Include /etc/apache2/sysconfig.d/global.conf

# optional mod_status, mod_info
Include /etc/apache2/mod_status.conf
Include /etc/apache2/mod_info.conf

# optional cookie-based user tracking
# read the documentation before using it!!
Include /etc/apache2/mod_usertrack.conf

# configuration of server-generated directory listings
Include /etc/apache2/mod_autoindex-defaults.conf

# associate MIME types with filename extensions
TypesConfig /etc/apache2/mime.types
DefaultType text/plain
Include /etc/apache2/mod_mime-defaults.conf

# set up (customizable) error responses
Include /etc/apache2/errors.conf

Include /etc/apache2/ssl-global.conf
# List of resources to look for when the client requests a directory
DirectoryIndex index.html index.html.var
Include /etc/apache2/default-server.conf
Include /etc/apache2/sysconfig.d/include.conf

<VirtualHost *>
    
ServerName cam34.com
ServerAdmin webmaster@dummy-host.example.com

DocumentRoot /srv/www/htdocs

    # if not specified, the global error log is used
    ErrorLog /var/log/apache2/mud-error_log
    LogLevel Debug
    CustomLog /var/log/apache2/mud-access_log combined
    LogLevel Debug
    # don't loose time with IP address lookups
    HostnameLookups Off

    # needed for named virtual hosts
    UseCanonicalName On

    # configures the footer on server-generated documents
    ServerSignature On
    #
    # This should be changed to whatever you set DocumentRoot to.
    #
    <Directory "/srv/www/htdocs">

        Options Indexes FollowSymLinks
        AllowOverride None
        Order allow,deny
        Allow from all

    </Directory>

</VirtualHost>


NameVirtualHost *

<VirtualHost *>
ServerName tim.com
ServerAdmin webmaster@dummy-host.example.com
        ProxyPass / http://192.168.1.100/
 
        ProxyPassReverse / http://192.168.1.100/

    # DocumentRoot: The directory out of which you will serve your
    # documents. By default, all requests are taken from this directory, but
    # symbolic links and aliases may be used to point to other locations.


    # if not specified, the global error log is used
    ErrorLog /var/log/apache2/moth-error_log
    LogLevel Debug
     CustomLog /var/log/apache2/moth-access_log combined
        Loglevel Debug
    # don't loose time with IP address lookups
    HostnameLookups Off

    # needed for named virtual hosts
    UseCanonicalName On

    # configures the footer on server-generated documents
    ServerSignature On
    #
    # This should be changed to whatever you set DocumentRoot to.
    #
    #<Directory "/srv/www/htdocs">

#        Options Indexes FollowSymLinks
 #       AllowOverride None
  #      Order allow,deny
   #     Allow from all

    #</Directory>
#ProxyRequests Off
<proxy>
          Order deny,allow
 
          Allow from all
</proxy>
</VirtualHost>

Last edited by cam34; 02-19-2009 at 12:18 AM.. Reason: code tags broken?
cam34 is offline     Reply With Quote

Reply

Bookmarks


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
about the URL when using Apache mod_proxy myhnet Linux - Newbie 0 06-25-2008 04:44 PM
Apache + Mod_proxy ProxyPass paul_mat Linux - Networking 2 04-14-2006 09:57 PM
Apache 1.3 mod_proxy no cache mago Linux - Software 0 04-07-2006 01:39 PM
Apache: Alias is working on ssl vhost but not on mass vhost jonavogt Linux - Software 0 06-07-2005 03:05 PM
Webmin Through Apache using mod_proxy... ech310n Linux - General 0 01-28-2004 05:12 PM


All times are GMT -5. The time now is 02:25 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
RSS2  LQ Podcast
RSS2  LQ Radio
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration