Uploaded image for project: 'ActiveMQ Artemis'
  1. ActiveMQ Artemis
  2. ARTEMIS-4674

How can I get client's real IP in an ActiveMQServerPlugin when using nginx proxy?

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Duplicate
    • 2.17.0
    • None
    • Broker, MQTT
    • None

    Description

      import org.apache.activemq.artemis.core.server.ServerConsumer;
      import org.apache.activemq.artemis.core.server.ServerSession;
      import org.apache.activemq.artemis.core.server.plugin.ActiveMQServerPlugin;
      
      public class AuthorPlugin implements ActiveMQServerPlugin {
      
          @Override
          public void registered(ActiveMQServer server) {
          }
      
          @Override
          public void afterCreateSession(ServerSession session) throws ActiveMQException {
              try {
                  RemotingConnection connection = session.getRemotingConnection();
                  //通过nginx 代理 artemismq 获取到IP 是 nginx 的本地IP: 172.16.34.112
                  //如何才能获取到连接客户端的远程IP
                  String remoteIp = connection.getRemoteAddress();
              } catch (Exception e) {
                  log.error(ExceptionUtils.getStackTrace(e));
              }
      
              ActiveMQServerPlugin.super.afterCreateSession(session);
          }

      ref:

       nignx emqx获取客户端真实ip_emqx虚拟机ip地址查询-CSDN博客

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              windynet windy
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: