# NGINX mail SMTP proxy - client ip

**URL:** <https://community.nginx.org/t/nginx-mail-smtp-proxy-client-ip/8091>\
**Category:** NGINX\
**Tags:** mail, reverse-proxy\
**Created:** [November 8, 2025, 7:34pm UTC](https://community.nginx.org/t/nginx-mail-smtp-proxy-client-ip/8091 "2025-11-08T19:34:32Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![desidnova](https://avatars.discourse-cdn.com/v4/letter/d/e47774/32.png) [@desidnova](https://community.nginx.org/u/desidnova)\
**Post date:** [November 8, 2025, 7:34pm UTC](https://community.nginx.org/t/nginx-mail-smtp-proxy-client-ip/8091/1 "2025-11-08T19:34:32Z")

</div>

Hello,

i have configured nginx to act as a mail proxy as per official doc:

> **[Configure NGINX as a Mail Proxy Server | NGINX Documentation](https://docs.nginx.com/nginx/admin-guide/mail-proxy/mail-proxy/)**
>
> Simplify your email service and improve its performance with NGINX or F5 NGINX Plus as a proxy for the IMAP, POP3, and SMTP protocols

All is fine i am able to send and receive emails through nginx mail proxy.

But after checking email headers sent through proxy it is clean that the “received from” part of message headers shows my nginx proxy ip address instead of client ip address which sent the email.

Can this be resolved somehow so that nginx will pass client ip instead of its own?

I saw some info in the docs regarding using settings like “set\_real\_ip\_from” or “proxy protocol” and “xclient” but if i understand correctly these all either require additional configuration in upstream mail server (which i do not own/manage) or are geared for http proxy not mail.

Thanks for any input.

---

<div class="post-metadata">

**Author:** ![alessandro](https://drob5swvtjqxg.cloudfront.net/user_avatar/community.nginx.org/alessandro/32/4836_2.png) [@alessandro](https://community.nginx.org/u/alessandro)\
**Post date:** [November 10, 2025, 1:06pm UTC](https://community.nginx.org/t/nginx-mail-smtp-proxy-client-ip/8091/2 "2025-11-10T13:06:58Z")

</div>

Hi @desidnova! Can you try setting up [`proxy_protocol on;`](https://nginx.org/en/docs/mail/ngx_mail_proxy_module.html#proxy_protocol) within your mail config? That might help you with extracting the client IP.

---

<div class="post-metadata">

**Author:** ![desidnova](https://avatars.discourse-cdn.com/v4/letter/d/e47774/32.png) [@desidnova](https://community.nginx.org/u/desidnova)\
**Post date:** [November 10, 2025, 3:54pm UTC](https://community.nginx.org/t/nginx-mail-smtp-proxy-client-ip/8091/3 "2025-11-10T15:54:05Z")

</div>

Thanks, i already tried that, unfortunately it seems that ‘proxy\_protocol’ set on listen directive is for nginx to accept incoming connections using proxy protocol ie.:

```auto
listen 993 proxy_protocol;

```

> **[Module ngx\_http\_core\_module](https://nginx.org/en/docs/http/ngx_http_core_module.html#listen)**

```auto
"The proxy_protocol parameter (1.5.12) allows specifying that all connections accepted on this port should use the PROXY protocol. "

```

While what is needed is that nginx mail proxy connect to upstream server with - maybe - proxy protocol. But as i understand the upstream server must also be configured to accept proxy protocol from my nginx mail proxy and then nginx could be configured to relay received proxy protocol data ie. using ‘set\_real\_ip\_from’ and/or other headers.

That’s the problematic part i don’t fully understand so correct me if i am wrong.

To clarify - i connect mail client ie. thunderbird to my nginx mail proxy, which then upstream mail server which i do not own/manage (ie. gmail).

---

<div class="post-metadata">

**Author:** ![alessandro](https://drob5swvtjqxg.cloudfront.net/user_avatar/community.nginx.org/alessandro/32/4836_2.png) [@alessandro](https://community.nginx.org/u/alessandro)\
**Post date:** [November 11, 2025, 1:13pm UTC](https://community.nginx.org/t/nginx-mail-smtp-proxy-client-ip/8091/4 "2025-11-11T13:13:55Z")

</div>

I am sadly not an expert on our SMTP integration, but hopefully someone else can shed a bit more information into this!

---

<div class="post-metadata">

**Author:** ![system](https://drob5swvtjqxg.cloudfront.net/user_avatar/community.nginx.org/system/32/19_2.png) [@system](https://community.nginx.org/u/system)\
**Post date:** [December 11, 2025, 1:14pm UTC](https://community.nginx.org/t/nginx-mail-smtp-proxy-client-ip/8091/5 "2025-12-11T13:14:52Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
