简体   繁体   中英

Configure base URL for ActiveMQ Web Console running behind a reverse proxy

We are running ActiveMQ Web Console behind an Nginx reverse proxy. The URL clients see is of the form https://host.example.org:8161/ . Nginx passes the following headers to the upstream ActiveMQ instance that listens on 127.0.0.1:8161 .

    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header X-Forwarded-Scheme $scheme;
    proxy_set_header X-Forwarded-Host $host:$server_port;
    proxy_set_header X-Forwarded-Server $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

Basic Web GUI works, but some actions fail. Eg sending a message to a topic seems to involve redirects to http://host.example.org/... which results in a HTTP 404 error.

I think the cause is that ActiveMQ Web Console does not know its base URL.

So how must ActiveMQ be configured to know its base URL, either through setting it explicitly or by deriving it from the headers sent by the reverse proxy?

Even though I am quite late :) I had the same issue and fixed it by adding a forwarded request customizer to the embedded jetty which serves the ActiveMQ web console. That way it will take account of the headers you provide via nginx.

You can do it by adding this to the jetty.xml within the conf folder of your ActiveMQ installation:

<bean id="forwardedRequestCustomizer"  class="org.eclipse.jetty.server.ForwardedRequestCustomizer"></bean>

<bean id="addCustomizers" class="org.springframework.beans.factory.config.MethodInvokingFactoryBean"
          depends-on="httpConfig, forwardedRequestCustomizer">
  <property name="targetObject" ref="httpConfig" />
  <property name="targetMethod" value="addCustomizer" />
  <property name="arguments" ref="forwardedRequestCustomizer" />
</bean>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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