Apache / AJP远程更改URI。为什么呢?

时间:2017-05-04 14:26:55

标签: apache tomcat uri ajp

我在Windows和Tomcat 7上使用Apache 2.4。到目前为止,我一直在测试我的localhost上的所有内容。所以我的本地Apache httpd.conf有这个......

<Location /sample>
    ProxyPass ajp://localhost:8079/sample
    ProxyPassReverse ajp://localhost:8079/sample
</Location>

现在我正在尝试在不同的系统上设置Apache并将其指向我的Tomcat系统。这是远程Apache httpd.conf的内容......

<Location /sample>
    ProxyPass ajp://192.168.2.93:8079/sample
    ProxyPassReverse ajp://192.168.2.93:8079/sample
</Location>

新的Remote Apache肯定会将请求转发给Tomcat,但它会将该位置预先添加到请求中。例如......

/sample/sample  

什么时候才应该......

/sample

本地和远程Apache httpd.conf之间唯一改变的是我将ProxyPass设置从localhost更改为IP。

我在这里缺少什么?这让我发疯了。

谢谢!

这是我当地的httpd.conf ....

# ================================================= 
# Modules 
# =================================================
LoadModule authz_core_module modules/mod_authz_core.so
LoadModule authz_host_module modules/mod_authz_host.so
LoadModule dir_module modules/mod_dir.so
LoadModule log_config_module modules/mod_log_config.so
LoadModule mime_module modules/mod_mime.so
LoadModule headers_module modules/mod_headers.so
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
#LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
LoadModule proxy_connect_module modules/mod_proxy_connect.so
LoadModule xml2enc_module modules/mod_xml2enc.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadFile    libxml2.dll
LoadModule  ssl_module    modules/mod_ssl.so
LoadModule  proxy_html_module    modules/mod_proxy_html.so
LoadModule rewrite_module modules/mod_rewrite.so
LoadModule deflate_module modules/mod_deflate.so
LoadModule substitute_module modules/mod_substitute.so
LoadModule filter_module modules/mod_filter.so
LoadModule socache_shmcb_module modules/mod_socache_shmcb.so
LoadModule setenvif_module modules/mod_setenvif.so
#LoadModule env_module modules/mod_env.so

Include conf/proxy_html.conf
Include conf/extra/httpd-ssl.conf

# ================================================= 
# Basic settings 
# ================================================= 
Listen 80
ServerName localhost:80
ServerAdmin fred@www.somedomain.com 
UseCanonicalName Off 
ServerSignature Off 
HostnameLookups Off 
ServerTokens Prod 
ServerRoot "D:/Apache24"
DocumentRoot "D:/Apache24/htdocs"

<IfModule mod_dir.c> 
   DirectoryIndex index.html index.htm index.php
</IfModule> 


# ================================================= 
# HTTP and performance settings 
# ================================================= 
Timeout 300 
KeepAlive On 
MaxKeepAliveRequests 100 
KeepAliveTimeout 15 
<IfModule mpm_winnt.c>
    ThreadsPerChild 64
    MaxRequestsPerChild  0
</IfModule>

# ================================================= 
# Logs: emerg, alert, crit, error, warn, notice, info, debug
# ================================================= 
  # Docs ~ http://httpd.apache.org/docs/2.4/mod/core.html#loglevel
  LogLevel alert rewrite:trace8 proxy_html:trace7
  LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined 
  LogFormat "%h %l %u %t \"%r\" %>s %b" common 
  LogFormat "%{Referer}i -> %U" referer 
  LogFormat "%{User-agent}i" agent 
  #ErrorLogFormat "[%t] [%l] [pid %P] %F: %E: [client %a] %M"
  ErrorLogFormat "[%l] %F ~ %M"
  ErrorLog "logs/error.log" 
  CustomLog "logs/access.log" combined
# ================================================= 

<VirtualHost *>
    ServerName localhost:80

    RewriteEngine On
    ProxyRequests off
    ProxyHTMLEnable Off

    <Proxy *>
      Require all granted
    </Proxy>

    <Location /sample>
        ProxyPass ajp://localhost:8079/sample
        ProxyPassReverse ajp://localhost:8079/sample
    </Location>
</VirtualHost>

1 个答案:

答案 0 :(得分:0)

我不知道为什么同样的Apache服务器(从一个系统到另一个系统的文字副本)会产生不同的URI,因为我将localhost更改为IP地址。但我通过从ProxyPass参数中删除<location/>包装器并使用这些参数来实现它...

ProxyPass /sample ajp://192.168.2.93:8079/sample
ProxyPassReverse /sample ajp://192.168.2.93:8079/sample

希望这有助于某人。