配置 apache 以针对特定名称进行反向代理

配置 apache 以针对特定名称进行反向代理

我有一个正常运行的内联网服务器:

  1. 正确提供部分内容http://hqmktgwb01/
  2. 当前已正确配置反向代理http://hqmktgwb01/dashstats到 localhost:3000 - localhost:3003 的循环
  3. 还有 DNS 名称dashstats(转到同一 IP)

当前工作配置文件可以在这里找到:http://pastie.org/1426082

我想修改配置以便:
   4.http://dashstats/执行相同的反向代理http://hqmktgwb01/dashstats

我尝试通过修改配置来实现#4:http://pastie.org/1426047(添加了第 90-98 行)但这不是有效的 Apache 配置。

请帮我修改原始配置文件以实现上述1-4。

答案1

我似乎已经使用这个配置让它工作了:http://pastie.org/1426986

我不确定这是否是最好的做法,但似乎有效。以下是完整配置,以防 Pastie 出现故障:

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 [email protected]
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>

相关内容