使用 Tomcat 配置 Apache Web 服务器
我正在尝试使用 AJP
配置 Tomcat
和 Apache
网络服务器,但我不确定我这样做是否正确。
以下是我遵循的步骤:
在 httpd.conf
文件中启用 requiredModule
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
在 httpd.conf
中添加了 ifModule
条件> 文件
<IfModule mod_proxy>
ProxyPass / ajp://localhost:8009/
ProxyPassMatch ^(/photos/.*\.jpg)$!
</IfModule>
Alias /photos "F:\projects\AL\Photos"
<Directory "F:\projects\AL\Photos">
Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>
最后,在 Tomcat
的 server.xml
文件中添加 Connector
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
现在,我尝试浏览到位于以下位置的 JSP 文件:以下位置:
http://localhost:8009/examples/jsp/jsp2/el/basic-arithmetic.jsp
这工作正常,但我想浏览 JSP:
http://localhost/examples/jsp/jsp2/el/basic-arithmetic.jsp.
我也尝试过这个:
<IfModule mod_proxy>
ProxyPass / ajp://localhost:8009/
ProxyPassReverse / ajp://localhost:8009/
ProxyPassMatch ^(/photos/.*\.jpg)$!
Alias /photos "F:\projects\AL\Photos"
< Directory "F:\projects\AL\Photos">
Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>
</IfModule>
然后我尝试浏览以下网址
http://localhost/examples/jsp/jsp2/el/basic-arithmetic.jsp
,但也不起作用。
我做得对吗?或者我还能做些什么?
I am trying to configure Apache
webserver with Tomcat
using AJP
, but I am not sure am I doing it right or not.
Here are the steps that I followed:
Enabled requiredModule
in httpd.conf
file
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
Added the ifModule
condition in httpd.conf
file
<IfModule mod_proxy>
ProxyPass / ajp://localhost:8009/
ProxyPassMatch ^(/photos/.*\.jpg)$!
</IfModule>
Alias /photos "F:\projects\AL\Photos"
<Directory "F:\projects\AL\Photos">
Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>
And finally, added the Connector
in the server.xml
file for Tomcat
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
Now, I am trying to browse to a JSP file at the following location:
http://localhost:8009/examples/jsp/jsp2/el/basic-arithmetic.jsp
This works fine, but I want to instead browse the JSP at:
http://localhost/examples/jsp/jsp2/el/basic-arithmetic.jsp.
I also tried this:
<IfModule mod_proxy>
ProxyPass / ajp://localhost:8009/
ProxyPassReverse / ajp://localhost:8009/
ProxyPassMatch ^(/photos/.*\.jpg)$!
Alias /photos "F:\projects\AL\Photos"
< Directory "F:\projects\AL\Photos">
Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>
</IfModule>
and then I tried to browse the following url
http://localhost/examples/jsp/jsp2/el/basic-arithmetic.jsp
which also does not work.
Have I done it right or there is something else that I can do?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
使用
指令。如: http ://stuff.mit.edu/afs/athena/project/stellar-dist/www/stellar2/apache2/stellar2-ajp-proxy.conf
注意:结尾后添加“/”非常重要你的 ajp 路径,否则配置将抛出 404 错误。
Use the
<Location>
directive.As in: http://stuff.mit.edu/afs/athena/project/stellar-dist/www/stellar2/apache2/stellar2-ajp-proxy.conf
NOTE: It is very important to add the "/" after ending your ajp path, else the configuration will throw a 404 error.
您还需要在“proxypass”之后添加“proxypassreverse”
You will also need the 'proxypassreverse' just after 'proxypass'
您是否在 Tomcat 的 server.xml 中启用了 AJP 连接器:
您不应该使用 AJP 端口来访问 Tomcat。 如果需要,您可以同时拥有 HTTP (8080) 和 AJP (8009) 连接器。 在这种情况下,您将直接在 localhost:8080 中访问 Tomcat
另外,正如 Ryan Fernandes 所说,您还需要 ProxyPassReverse 指令。
Have you enabled the AJP connector in Tomcat's server.xml:
You aren't supposed to use AJP port for accessing Tomcat. You can, if you want to, have both an HTTP (8080) and an AJP (8009) connector. In that case you will access Tomcat directly in localhost:8080
Also, as Ryan Fernandes said, you also need the ProxyPassReverse directive.