简体   繁体   English

nginx反向代理pop3将主机名发送到身份验证脚本

[英]nginx reverse proxy pop3 send hostname to auth script

I have set up a POP3 reverse proxy and is being used to serve multiple domains. 我已经设置了POP3反向代理,并用于服务多个域。 I was thinking to pass the hostname of the request to the auth script as a custom header, but I don't know how. 我当时想将请求的主机名作为自定义标头传递给auth脚本,但我不知道如何。

The relevant section of the nginx.conf file is: 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;
    }
}

I tried with this: 我尝试了这个:

auth_http_header my_hostname $host;

expecting nginx to replace the $host with the actual hostname, but it does not happen, the auth script receives $_SERVER[MY_HOSTNAME] = '$host'. 期望nginx用实际的主机名替换$ host,但是不会发生,身份验证脚本收到$ _SERVER [MY_HOSTNAME] ='$ host'。

Is there any way I can accomplish this? 我有什么办法可以做到这一点?

The only way to get the host of the auth, is authenticating like user@hostname.tld and in the auth headers split the part of the hostname. 获取身份验证主机的唯一方法是像user@hostname.tld一样进行身份验证,并在身份验证标头中拆分主机名的一部分。

If you want to proxy auth to multiple domains I wrote a module in perl 如果您想将身份验证代理到多个域,我在perl中编写了一个模块

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM