使用 Tomcat 配置 Apache Web 服务器

发布于 2024-07-27 05:07:13 字数 1763 浏览 9 评论 0原文

我正在尝试使用 AJP 配置 TomcatApache 网络服务器,但我不确定我这样做是否正确。

以下是我遵循的步骤:

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> 

最后,在 Tomcatserver.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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

橪书 2024-08-03 05:07:13

使用 指令。

如: 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.

皓月长歌 2024-08-03 05:07:13

您还需要在“proxypass”之后添加“proxypassreverse”

You will also need the 'proxypassreverse' just after 'proxypass'

赤濁 2024-08-03 05:07:13

您是否在 Tomcat 的 server.xml 中启用了 AJP 连接器:

<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />

您不应该使用 AJP 端口来访问 Tomcat。 如果需要,您可以同时拥有 HTTP (8080) 和 AJP (8009) 连接器。 在这种情况下,您将直接在 localhost:8080 中访问 Tomcat

另外,正如 Ryan Fernandes 所说,您还需要 ProxyPassReverse 指令。

Have you enabled the AJP connector in Tomcat's server.xml:

<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文