如何在Apache下代理Web请求到Lucee/Tomcat?

sulc1iza  于 2023-01-13  发布在  Apache
关注(0)|答案(1)|浏览(153)

我在CentOS 9机器上设置Lucce在Apache上运行时遇到了问题。我遵循的步骤如下:

  • 已从https://downloads.lucee.org安装. run文件
  • 保留apachectl、httpd conf和http模块的默认值(我已经检查过了,看起来它们是正确的,如果需要,我可以提供值)
  • 设置Tomcat在端口8888上运行,这是默认值(Tomcat实际上正在运行,因为我可以从外部访问它)
  • 已接受安装Apache连接器
  • 已接受安装mod_cfml

然后,当Lucee正在安装时,我收到一个安装后步骤错误,指出安装可能无法正确完成:

Error running /opt/lucee/sys/install_mod_proxy.sh -m install -t 8888 -f
/etc/httpd/conf/httpd.conf -c /usr/sbin/apachectl: apachectl: The "-M" option is
not supported.
apachectl: The "-M" option is not supported.

但是安装过程结束了,一切似乎都很好。

  • Tomcat正在运行(我可以通过domain.com:8888访问)
  • 使用以下规则将代理添加到httpd.conf文件
<IfModule mod_proxy.c>
        ProxyPreserveHost On
        ProxyPassMatch ^/(.+\.cf[cm])(/.*)?$ http://127.0.0.1:8888/$1$2
        ProxyPassMatch ^/(.+\.cfml)(/.*)?$ http://127.0.0.1:8888/$1$2
        # optional mappings
        #ProxyPassMatch ^/flex2gateway/(.*)$ http://127.0.0.1:8888/flex2gateway/$1
        #ProxyPassMatch ^/messagebroker/(.*)$ http://127.0.0.1:8888/messagebroker/$1
        #ProxyPassMatch ^/flashservices/gateway(.*)$ http://127.0.0.1:8888/flashservices/gateway$1
        #ProxyPassMatch ^/openamf/gateway/(.*)$ http://127.0.0.1:8888/openamf/gateway/$1
        #ProxyPassMatch ^/rest/(.*)$ http://127.0.0.1:8888/rest/$1
        ProxyPassReverse / http://127.0.0.1:8888/
</IfModule>
  • mod_cfml加载到httpd.conf文件中
LoadModule modcfml_module modules/mod_cfml.so
CFMLHandlers ".cfm .cfc .cfml"
ModCFML_SharedKey "{{ shared_key_here }}"
LogHeaders false
LogHandlers false
LogAliases false
VDirHeader false

最后,我重新启动了Lucee和Apache服务,并在/var/www/html中创建了一个index.cfm文件,但当我尝试访问它时,我得到了一个503错误。
The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.
Tomcat的catalina.out日志和Apache的error_logs没有给我任何提示。
有人能给我指出解决这个问题的方向吗?
任何额外的信息,你可能需要,以帮助我下跌自由问.
谢谢。

anauzrmj

anauzrmj1#

所以我发现我的机器启用了SE(Security Enhanced,安全增强),并且有一个设置阻止请求正确地代理到Tomcat,即httpd_can_network_connect
我必须运行/usr/sbin/setsebool httpd_can_network_connect true才能使它工作,在此之后并重新启动httpd服务,一切都很好!

相关问题