You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@activemq.apache.org by "Justin Bertram (Jira)" <ji...@apache.org> on 2024/03/07 03:48:00 UTC
[jira] [Closed] (ARTEMIS-4674) How can I get client's real IP in an ActiveMQServerPlugin when using nginx proxy?
[ https://issues.apache.org/jira/browse/ARTEMIS-4674?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Justin Bertram closed ARTEMIS-4674.
-----------------------------------
Resolution: Duplicate
> How can I get client's real IP in an ActiveMQServerPlugin when using nginx proxy?
> ---------------------------------------------------------------------------------
>
> Key: ARTEMIS-4674
> URL: https://issues.apache.org/jira/browse/ARTEMIS-4674
> Project: ActiveMQ Artemis
> Issue Type: Bug
> Components: Broker, MQTT
> Affects Versions: 2.17.0
> Reporter: windy
> Priority: Major
>
> {code:java}
> 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);
> }{code}
> ref:
> [ nignx emqx获取客户端真实ip_emqx虚拟机ip地址查询-CSDN博客|https://blog.csdn.net/weixin_41459256/article/details/129319646]
--
This message was sent by Atlassian Jira
(v8.20.10#820010)