You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

ActiveMQ内置Jetty:如何将HTTP重定向到HTTPS并修正日志协议显示?

ActiveMQ Jetty控制台HTTPS配置问题解决方案

问题1:HTTP请求重定向到HTTPS的实现方法

完全可行,具体配置步骤如下:

  • 保留原有HTTP Connector(不要注释),确保它正常监听默认的8161端口(或自定义的HTTP端口)。
  • 在jetty.xml的Server配置中添加Jetty的SecureRedirectHandler,让所有HTTP请求自动重定向到HTTPS端口,配置示例:
<bean id="Server" class="org.eclipse.jetty.server.Server">
    <!-- 保留原有Server相关配置 -->
    <property name="handler">
        <bean class="org.eclipse.jetty.server.handler.HandlerCollection">
            <property name="handlers">
                <list>
                    <!-- 新增重定向处理器 -->
                    <bean id="SecureRedirectHandler" class="org.eclipse.jetty.server.handler.SecureRedirectHandler">
                        <property name="securePort" value="8162"/> <!-- 你的HTTPS端口 -->
                        <property name="secureScheme" value="https"/>
                    </bean>
                    <!-- 保留原有控制台、Jolokia等handler引用 -->
                    <ref bean="WebConsoleContext"/>
                    <ref bean="JolokiaContext"/>
                </list>
            </property>
        </bean>
    </property>
</bean>
  • 保留你已配置好的HTTPS SecureConnector,重启ActiveMQ后,访问HTTP端口会自动跳转到HTTPS端口。

问题2:修正启动日志中的协议显示

日志协议显示错误是因为WebConsoleStarter默认使用HTTP协议生成日志,可通过两种方式修正:

方式1:修改启动脚本添加系统属性

在ActiveMQ启动脚本(如activemq或wrapper.conf)中添加以下系统属性:

-Dactivemq.webconsole.protocol=https
-Dactivemq.jolokia.protocol=https

方式2:修改jetty.xml的控制台上下文配置

找到WebConsoleContext的bean配置,添加初始化参数指定协议:

<bean id="WebConsoleContext" class="org.eclipse.jetty.webapp.WebAppContext">
    <!-- 保留原有配置 -->
    <property name="initParams">
        <map>
            <entry key="activemq.webconsole.protocol" value="https"/>
        </map>
    </property>
</bean>

重启ActiveMQ后,启动日志就会显示正确的https://0.0.0.0:8162/格式地址。

内容的提问来源于stack exchange,提问作者mmo

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.11 15:30:51