haproxy 背后的 nginx 邮件代理 - 获取客户端的真实 IP 地址
nginx mail proxy behind haproxy - get clients real ip address
我使用 nginx 作为邮件代理,用于身份验证和其他一些附加功能。但是我需要在 nginx 前面使用另一个代理(比如 haproxy)。一切正常,一切正常。但是 nginx 无法检索客户端的真实 IP 地址。
在 http 模块中,我可以使用 x-forwarded-for header 和 nginx 的 proxy_protocol 转发它。但是在邮件模块中,我不能那样做。邮件模块不支持 proxy_protocol.
有什么办法,如何将客户端的真实IP地址传给nginx?
我的 haproxy 和 nginx 配置类似;
haproxy.cfg:
frontend IMAP
bind 0.0.0.0:143 name IMAP tcp-ut 30s
default_backend IMAP
backend IMAP
option tcp-check
tcp-check connect port 11143
tcp-check expect string * OK
server localhost 127.0.0.1:11143 send-proxy check
nginx.conf
mail {
auth_http 127.0.0.1:333/auth;
proxy on;
imap_auth plain;
server {
listen 11143;
protocol imap;
auth_http_header proxyprotocol imap;
}
}
该指令出现在版本 1.19.8 中。
http://nginx.org/en/docs/mail/ngx_mail_proxy_module.html#proxy_protocol
server {
server_name ImapServer;
listen 11143 proxy_protocol;
protocol imap;
}
我使用 nginx 作为邮件代理,用于身份验证和其他一些附加功能。但是我需要在 nginx 前面使用另一个代理(比如 haproxy)。一切正常,一切正常。但是 nginx 无法检索客户端的真实 IP 地址。
在 http 模块中,我可以使用 x-forwarded-for header 和 nginx 的 proxy_protocol 转发它。但是在邮件模块中,我不能那样做。邮件模块不支持 proxy_protocol.
有什么办法,如何将客户端的真实IP地址传给nginx?
我的 haproxy 和 nginx 配置类似;
haproxy.cfg:
frontend IMAP
bind 0.0.0.0:143 name IMAP tcp-ut 30s
default_backend IMAP
backend IMAP
option tcp-check
tcp-check connect port 11143
tcp-check expect string * OK
server localhost 127.0.0.1:11143 send-proxy check
nginx.conf
mail {
auth_http 127.0.0.1:333/auth;
proxy on;
imap_auth plain;
server {
listen 11143;
protocol imap;
auth_http_header proxyprotocol imap;
}
}
该指令出现在版本 1.19.8 中。
http://nginx.org/en/docs/mail/ngx_mail_proxy_module.html#proxy_protocol
server {
server_name ImapServer;
listen 11143 proxy_protocol;
protocol imap;
}