简体   繁体   English

使用Tomcat配置Apache Web服务器

[英]Configuring Apache Web Server with Tomcat

I am trying to configure Apache webserver with Tomcat using AJP , but I am not sure am I doing it right or not. 我正在尝试使用AJP使用Tomcat配置Apache Web服务器,但是不确定执行正确与否。

Here are the steps that I followed: 这是我遵循的步骤:

Enabled requiredModule in httpd.conf file httpd.conf文件中启用了requiredModule

LoadModule proxy_module modules/mod_proxy.so  
LoadModule proxy_ajp_module modules/mod_proxy_ajp.so  

Added the ifModule condition in httpd.conf file 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> 

And finally, added the Connector in the server.xml file for Tomcat 最后,将Connector添加到Tomcatserver.xml文件中

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

Now, I am trying to browse to a JSP file at the following location: 现在,我尝试浏览到以下位置的JSP文件:

http://localhost:8009/examples/jsp/jsp2/el/basic-arithmetic.jsp

This works fine, but I want to instead browse the JSP at: 这个工作正常,但是我想浏览以下站点的JSP:

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? 我做对了还是还有其他可以做的事情?

Use the <Location> directive. 使用<Location>指令。

As in: http://stuff.mit.edu/afs/athena/project/stellar-dist/www/stellar2/apache2/stellar2-ajp-proxy.conf 如在: 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. 注意:在结束ajp路径后添加“ /”非常重要,否则配置将引发404错误。

在“ proxypass”之后,您还需要“ proxypassreverse”

Have you enabled the AJP connector in Tomcat's server.xml: 您是否在Tomcat的server.xml中启用了AJP连接器:

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

You aren't supposed to use AJP port for accessing Tomcat. 您不应该使用AJP端口访问Tomcat。 You can, if you want to, have both an HTTP (8080) and an AJP (8009) connector. 如果需要,可以同时具有HTTP(8080)和AJP(8009)连接器。 In that case you will access Tomcat directly in localhost:8080 在这种情况下,您将直接在localhost:8080中访问Tomcat。

Also, as Ryan Fernandes said, you also need the ProxyPassReverse directive. 另外,正如Ryan Fernandes所说,您还需要ProxyPassReverse指令。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM