gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-28 23:21:02 26 4
gpt4 key购买 nike

我在 Windows 和 Tomcat 7 上使用 Apache 2.4。到目前为止,我一直在本地主机上测试所有内容。所以我本地的 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 设置从本地主机更改为 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>

最佳答案

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

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

希望这对某人有帮助。

关于Apache/AJP 远程更改 URI。为什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43785649/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com