gpt4 book ai didi

tomcat - 使用 mod_rewrite 的 AJP 代理设置

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

我的 AJP 代理设置有问题。

软件版本
Oracle Linux Server 6.5、Apache 2.2.15、Apache Tomcat 7.0.29、tomcat-connectors-1.2.37-src。

预期行为
<em>With slash at the end of URL</em><br/>
http:/@/name.company.local/application/ --> http:/@/name.company.local:8080/application/ <br/><strong>It works => OK</strong><br/>
<br/><em>Without slash at the end of URL</em><br/>http:/@/name.company.local/application -> http:/@/name.company.local:8080/application <br/><strong>It does NOT work => K.O.</strong><br/>
<br/><em>With path after app name</em><br/>http:/@/name.company.local/some/path -> http:/@/name.company.local:8080/application/some/path <br/><strong>It does NOT work => K.O.</strong>

Apache 日志文件 (var/log/httpd/name.company.local-error_log)

[Fri Dec 13 10:48:33 2013] [error] [client 10.0.100.26] File does not exist: /var/www/name.company.local/application[Fri Dec 13 10:48:33 2013] [error] [client 10.0.100.26] File does not exist: /var/www/name.company.local/application

AJP 代理设置 (/etc/httpd/conf.d/ajp.conf)

ProxyRequests Off<br/>
<Proxy *><br/>
  Order deny,allow<br/>
  Deny from all<br/>
  Allow from localhost<br/>
</Proxy><br/>
ProxyPass /application ajp://localhost:8009/application<br/>
ProxyPassReverse /application ajp://localhost:8009/application

Apache 设置 (/etc/httpd/conf/httpd)


NameVirtualHost *:80<br/>
NameVirtualHost *:443<br/>
ServerName name.company.local<br/><br/>
<VirtualHost *:80><br/>
   ServerAdmin webmaster@company.cz<br/>
   DocumentRoot /var/www/name.company.local<br/>
   ServerName name.company.local<br/>
   ServerAlias application<br/><br/>
   RewriteEngine On<br/>
   RewriteLog "/var/log/httpd/rewrite.log"<br/>
   RewriteLogLevel 9<br/>
   RewriteCond %{HTTP_HOST} !.local$<br/>
   RewriteRule ^/(.*)$ http:/@/name.company.local/$1 [R=301]<br/>
   RewriteCond %{REQUEST_URI} !^/application/<br/>
   RewriteRule ^/(.*)$ /application/$1<br/>
   LogFormat "%h %l %u %t \"%r\" %>s %b \"%{User-Agent}i\"" appspecial<br/>
   ErrorLog logs/name.company.local-error_log<br/>
   CustomLog logs/name.company.local-access_log appspecial<br/></VirtualHost>

你能告诉我,哪里出了问题吗?或者我该如何调试它?

问候

鹦鹉螺

附言由于 Stack Overflow 的声誉较低(我是新手),我不能使用超过 2 个链接,因此我不得不将有效的 HTTP 协议(protocol)前缀替换为 http:/@/。

最佳答案

我通过更改重写规则解决了 URL 末尾没有斜杠 的问题:

RewriteCond %{REQUEST_URI} !^/application<br/>
RewriteRule ^/(.*)$ /application/$1

我还解决了应用程序名称后的路径问题,再次修改了重写规则:
RewriteCond %{REQUEST_URI} !^/application<br/>
RewriteRule ^/(.*)$ <a href="http://name.company.local/application/" rel="noreferrer noopener nofollow">http://name.company.local/application/</a>$1<br/>

关于tomcat - 使用 mod_rewrite 的 AJP 代理设置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20546982/

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