# Nginx imap proxy problem

**URL:** <https://www.ruby-forum.com/t/nginx-imap-proxy-problem/205032>\
**Category:** NGINX\
**Created:** [March 27, 2011, 11:19pm UTC](https://www.ruby-forum.com/t/nginx-imap-proxy-problem/205032 "2011-03-27T23:19:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [March 27, 2011, 11:19pm UTC](https://www.ruby-forum.com/t/nginx-imap-proxy-problem/205032/1 "2011-03-27T23:19:43Z")

</div>

Hi,

I try to use this php script:

> **[Using a PHP Script on an Apache Server as the IMAP Auth Backend | NGINX](https://www.nginx.com/resources/wiki/start/topics/examples/imapauthenticatewithapachephpscript/)**
>
> An example NGINX configuration that uses a PHP script on an Apache server as the IMAP auth backend.

But all I get is:

auth http server [web-srv.de:80](http://web-srv.de:80) did not send server or port while in http  
auth state, client: , server: mail-srv:993, login:  
“[foo@bar](mailto:foo@bar)”

I guess it’s the php script but don’t know where in the script I have to  
look for the error.

Regards,  
alokat

---

<div class="post-metadata">

**Author:** ![Alokat](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ea666f/32.png) [@Alokat](https://www.ruby-forum.com/u/Alokat)\
**Post date:** [March 27, 2011, 11:25pm UTC](https://www.ruby-forum.com/t/nginx-imap-proxy-problem/205032/2 "2011-03-27T23:25:20Z")

</div>

On 03/27/11 23:19, Alokat wrote:

> “[foo@bar](mailto:foo@bar)”  
> [mailman.nginx.org archive](http://nginx.org/mailman/listinfo/nginx)  
> And I’m using lighttpd as auth server.

Regards,  
alokat

---

<div class="post-metadata">

**Author:** ![Alokat](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ea666f/32.png) [@Alokat](https://www.ruby-forum.com/u/Alokat)\
**Post date:** [March 28, 2011, 1:50pm UTC](https://www.ruby-forum.com/t/nginx-imap-proxy-problem/205032/3 "2011-03-28T13:50:52Z")

</div>

On Sun, Mar 27, 2011 at 11:24:44PM +0200, Alokat wrote:

> On 03/27/11 23:19, Alokat wrote:

Hi there,

> > I try to use this php script:
> > 
> > [GitHub - nginxinc/nginx-wiki: ARCHIVED -- Source for the now archived NGINX Wiki section of https://www.nginx.com · GitHub](http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript)

When I copy-paste that script, “php -l” eventually shows me three lines  
with syntax errors that can be fixed by adding some parentheses.

> > But all I get is:
> > 
> > auth http server web-srv.de:80 did not send server or port while in  
> > http auth state, client: , server: mail-srv:993, login:  
> > “[foo@bar](mailto:foo@bar)”

Unmodified, you will probably get a http 500 back from the server. That  
would lead to this error message.

> > I guess it’s the php script but don’t know where in the script I have  
> > to look for the error.

“php -l”, or the (php-running) server error log should point at the  
lines. Then you can fix them while adding your own password-verification  
and server-selection code.

> And I’m using lighttpd as auth server.

That’s where to find the php errors, then.

[GitHub - nginxinc/nginx-wiki: ARCHIVED -- Source for the now archived NGINX Wiki section of https://www.nginx.com · GitHub](http://wiki.nginx.org/MailCoreModule#Authentication) describes what http  
request nginx makes, and what response it expects.

The GET and Host: lines come from your auth\_http configuration.

The Auth-User: and Auth-Pass: lines come from your mail client.

I suggest you mimic the nginx http request manually, using something  
like

curl -i -H ‘Auth-User: whoever’ -H ‘Auth-Pass: whatever’  
[http://example.com/auth](http://example.com/auth)

to confirm that you get the correct “pass” and “fail” responses from  
your auth script. Once that is working, you can test the nginx setup.

Good luck with it,

## f

Francis D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
