【问题标题】:How to proxy web requests to Lucee/Tomcat under Apache?如何在 Apache 下将 Web 请求代理到 Lucee/Tomcat?
【发布时间】:2023-01-11 11:01:35
【问题描述】:

我无法将 Lucce 设置为在 CentOS 9 机器的 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 没有给我任何关于正在发生的事情的提示。

谁能指出我解决这个问题的任何方向?

您可能需要任何其他信息来帮助我随时提问。

谢谢。

【问题讨论】:

  • 安装程序可能无法为您的 apache2 安装/激活 mod_proxy。看起来选项 -M 在 Centos 上失败,因为列出模块的命令在 Centos 上可能不同(“httpd -M”而不是“apachectl -M”,这可能是问题的原因)。
  • 感谢您的回复,但是,安装程序确实激活/安装了 mod_proxy 和 mod_cfml,我发现机器启用了 SELinux,并且有一个设置阻止将请求正确代理到 tomcat httpd_can_network_connect=false,我不得不将其更改为httpd_can_network_connect=true。但是谢谢@AndreasRu

标签: apache tomcat lucee


【解决方案1】:

所以我发现我的机器启用了SE(安全增强),并且有一个设置阻止请求被正确代理到tomcat,这是httpd_can_network_connect

我必须运行 /usr/sbin/setsebool httpd_can_network_connect true 才能让它工作,在此之后并重新启动 httpd 服务,一切正常!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2010-09-12
    • 2013-03-02
    • 2015-11-23
    • 2014-02-18
    • 2011-02-06
    • 1970-01-01
    • 2015-03-15
    • 1970-01-01
    相关资源
    最近更新 更多