Configure apache to reverse proxy for specific name

apache-2.2configuration

I have a working intranet server that:

  1. Properly serves some content from http://hqmktgwb01/
  2. Is currently properly configured to reverse proxy from http://hqmktgwb01/dashstats to a round-robin of localhost:3000 – localhost:3003
  3. Also has the DNS name dashstats (going to the same IP)

The current working configuration file can be found here: http://pastie.org/1426082

I would like to modify the configuration so that:
   4. http://dashstats/ performs the same reverse proxying http://hqmktgwb01/dashstats.

I tried to achieve #4 by modifying the config like this: http://pastie.org/1426047 (added lines 90-98) but this is not a valid Apache config.

Please help me to modify the original config file to accomplish 1-4 above.

Best Answer

I seem to have gotten it working using this configuration: http://pastie.org/1426986

I'm not certain that it is the best practice, but it appears to be working. Full config included below in case Pastie goes down:

ServerRoot "C:/Program Files/Apache Software Foundation/Apache2.2"
Listen 80

LoadModule actions_module modules/mod_actions.so
LoadModule alias_module modules/mod_alias.so
LoadModule asis_module modules/mod_asis.so
LoadModule auth_basic_module modules/mod_auth_basic.so
LoadModule authn_default_module modules/mod_authn_default.so
LoadModule authn_file_module modules/mod_authn_file.so
LoadModule authz_default_module modules/mod_authz_default.so
LoadModule authz_groupfile_module modules/mod_authz_groupfile.so
LoadModule authz_host_module modules/mod_authz_host.so
LoadModule authz_user_module modules/mod_authz_user.so
LoadModule autoindex_module modules/mod_autoindex.so
LoadModule cgi_module modules/mod_cgi.so
LoadModule dir_module modules/mod_dir.so
LoadModule env_module modules/mod_env.so
LoadModule headers_module modules/mod_headers.so
LoadModule include_module modules/mod_include.so
LoadModule isapi_module modules/mod_isapi.so
LoadModule log_config_module modules/mod_log_config.so
LoadModule mime_module modules/mod_mime.so
LoadModule negotiation_module modules/mod_negotiation.so
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
LoadModule proxy_http_module modules/mod_proxy_http.so

LoadFile   modules/mod_proxy_html/zlib.dll
LoadFile   modules/mod_proxy_html/iconv.dll
LoadFile   modules/mod_proxy_html/libxml2.dll
LoadModule proxy_html_module modules/mod_proxy_html/mod_proxy_html.so
LoadModule xml2enc_module modules/mod_proxy_html/mod_xml2enc.so

LoadModule setenvif_module modules/mod_setenvif.so

<IfModule !mpm_netware_module>
<IfModule !mpm_winnt_module>
User daemon
Group daemon
</IfModule>
</IfModule>

ProxyHTMLLinks  a       href
ProxyHTMLLinks  area        href
ProxyHTMLLinks  link        href
ProxyHTMLLinks  img     src longdesc usemap
ProxyHTMLLinks  object      classid codebase data usemap
ProxyHTMLLinks  q       cite
ProxyHTMLLinks  blockquote  cite
ProxyHTMLLinks  ins     cite
ProxyHTMLLinks  del     cite
ProxyHTMLLinks  form        action
ProxyHTMLLinks  input       src usemap
ProxyHTMLLinks  head        profile
ProxyHTMLLinks  base        href
ProxyHTMLLinks  script      src for

xml2EncDefault UTF-8

ServerAdmin mewho@mydomain.com
ServerName hqmktgwb01.mydomain.com:80

<Proxy balancer://dashstats/>
    BalancerMember http://127.0.0.1:3000
    BalancerMember http://127.0.0.1:3001
    BalancerMember http://127.0.0.1:3002
    BalancerMember http://127.0.0.1:3003
    ProxySet lbmethod=bybusyness
</Proxy>

ProxyRequests Off

<Directory c:/www/nvdlstats/public>
    Order allow,deny
    Allow from all
</Directory>

###########################################################################################

NameVirtualHost *:80
<VirtualHost *:80>
    ServerName hqmktgwb01.nvidia.com
    ServerAlias hqmktgwb01
    DocumentRoot "E:/htdocs"


    ProxyPass /dashstats/css !
    ProxyPass /dashstats/js !
    ProxyPass /dashstats/images !

    ProxyPass        /dashstats/ balancer://dashstats/
    ProxyPassReverse /dashstats/ balancer://dashstats/
    <Location /dashstats/>
        ProxyPassReverse /
        ProxyHTMLEnable On
        ProxyHTMLURLMap balancer://dashstats/ /dashstats/
        ProxyHTMLURLMap / /dashstats/
    </Location>


    RedirectMatch ^/dashstats$ /dashstats/

    <Directory />
        Options FollowSymLinks
        AllowOverride None
        Order deny,allow
        Deny from all
    </Directory>

    <Directory "E:/htdocs">
        Options Indexes FollowSymLinks
        AllowOverride None
        Order allow,deny
        Allow from all
    </Directory>

    <IfModule alias_module>
        Alias /dashstats/css c:/www/nvdlstats/public/css
        Alias /dashstats/js c:/www/nvdlstats/public/js
        Alias /dashstats/images c:/www/nvdlstats/public/images

        ScriptAlias /cgi-bin/ "C:/Program Files/Apache Software Foundation/Apache2.2/cgi-bin/"
    </IfModule>

    <IfModule dir_module>
        DirectoryIndex index.html
    </IfModule>

</VirtualHost>

###########################################################################################
###########################################################################################
###########################################################################################

<VirtualHost *:80>
    ServerName dashstats.nvidia.com
    ServerAlias dashstats
    DocumentRoot "C:/www/nvdlstats/public"

    ProxyPass /css !
    ProxyPass /js !
    ProxyPass /images !

    ProxyPass        / balancer://dashstats/
    ProxyPassReverse / balancer://dashstats/
</VirtualHost>

###########################################################################################

<Directory "C:/Program Files/Apache Software Foundation/Apache2.2/cgi-bin">
    AllowOverride None
    Options None
    Order allow,deny
    Allow from all
</Directory>

<FilesMatch "^\.ht">
    Order allow,deny
    Deny from all
    Satisfy All
</FilesMatch>

ErrorLog "logs/error.log"
LogLevel warn

<IfModule log_config_module>
    LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
    LogFormat "%h %l %u %t \"%r\" %>s %b" common

    <IfModule logio_module>
        LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
    </IfModule>
    CustomLog "logs/access.log" common
</IfModule>

DefaultType text/plain

<IfModule mime_module>
    TypesConfig conf/mime.types
    AddType application/x-compress .Z
    AddType application/x-gzip .gz .tgz
</IfModule>

LoadModule php5_module "c:/php/php5apache2_2.dll"
AddType application/x-httpd-php .php

PHPIniDir "C:/php"

<IfModule ssl_module>
    SSLRandomSeed startup builtin
    SSLRandomSeed connect builtin
</IfModule>

<IfModule headers_module>
    Header set X-UA-Compatible: IE=8
</IfModule>