nginx反向代理pop3将主机名发送到auth脚本

时间:2014-05-16 16:07:04

标签: nginx reverse-proxy pop3

我已经设置了POP3反向代理,并且用于为多个域提供服务。我想将请求的主机名作为自定义标头传递给auth脚本,但我不知道如何。

nginx.conf文件的相关部分是:

mail {
    server_name mail.example.com;
    auth_http  10.169.15.199:80/auth_script.php;
    auth_http_timeout 5000;
    proxy  on;
    proxy_pass_error_message on;

    pop3_capabilities "LAST" "TOP" "USER" "PIPELINING" "UIDL";

    server {
      protocol    pop3;
      listen      110;
      pop3_auth   plain;
      auth_http_header X-Auth-Port 110;
      auth_http_header User-Agent "Nginx POP3/IMAP4 proxy";
      auth_http_header my_hostname $host;
    }
}

我试过这个:

auth_http_header my_hostname $host;

期望nginx用实际的主机名替换$ host,但是不会发生,auth脚本会收到$ _SERVER [MY_HOSTNAME] =' $ host'。

我有什么方法可以做到这一点吗?

1 个答案:

答案 0 :(得分:0)

获取auth主机的唯一方法是进行身份验证,如user@hostname.tld,并在auth标头中拆分主机名的一部分。

如果您想将auth代理到多个域,我写了一个module in perl

相关问题