簡體   English   中英

haproxy 背后的 nginx 郵件代理 - 獲取客戶端的真實 IP 地址

[英]nginx mail proxy behind haproxy - get clients real ip address

我使用 nginx 作為郵件代理,用於身份驗證和其他一些附加功能。 但是我需要在 nginx 前面使用另一個代理(如 haproxy)。 一切正常,一切正常。 但是 nginx 無法檢索客戶端的真實 IP 地址。

在 http 模塊中,我可以使用 x-forwarded-for 標頭和 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

配置文件

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;
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM