2017-05-04 54 views
0

我在Windows和Tomcat 7上使用Apache 2.4。到目前爲止,我一直在測試我的本地主機上的所有內容。所以我的本地Apache httpd.conf有這個...Apache/AJP遠程更改URI。爲什麼?

<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> 

新的遠程Apache是​​絕對將請求轉發到Tomcat,但它前面加上位置的請求。例如...

/sample/sample 

當它應該是唯一的......

/sample 

本地和遠程的Apache httpd.conf的是我改變了的ProxyPass設置從本地主機之間改變是唯一的事情一個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 [email protected] 
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> 

回答

0

我不知道爲什麼完全相同的Apache服務器(從一個系統到另一個文本複印件)會產生不同的URI,因爲我改變了本地主機一個IP地址。但我得到了它通過從ProxyPass僞參數<location/>包裝,並使用這些參數,而不是工作...

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

希望這可以幫助別人。