<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
<html><body style='font-size: 10pt; font-family: Verdana,Geneva,sans-serif'>
<p>I don't know what is wrong with your config... I guess your smtp server does not answer properly.</p>
<p>Is 127.0.0.2:143 really your <strong>SMTP</strong>-server? <br />Because port 143 is mostly an <strong>IMAP</strong> port - but you've specified <span style="background-color: #efefef; font-family: courier new,courier;"><strong>protocol smtp</strong></span> in the server section.</p>
<p>Anyway I tested your config with my settings (replaced name and smtp-server, here 192.0.2.222:25) and enabled debug:</p>
<p style="padding-left: 30px;"><span style="font-family: courier new,courier; background-color: #ccffcc;">+ error_log logs/error-mail.log<span style="background-color: #00ff00;"> <strong>debug</strong></span>;</span><br /><span style="font-family: courier new,courier;"> mail {</span><br /><span style="font-family: courier new,courier; background-color: #ffcc99;"> - server_name localhost;</span><br /><span style="font-family: courier new,courier;"><span style="background-color: #ccffcc;"> + server_name <strong><span style="background-color: #00ff00;">example.com</span></strong>;</span><br />...<br /> http {<br /><span style="font-family: courier new,courier;">...<br /></span><span style="background-color: #ffcc99;"> - add_header Auth-Server 127.0.0.2;</span><br /><span style="background-color: #ffcc99;"> - add_header Auth-Port 143;</span><br /><span style="background-color: #ccffcc;"><span style="font-family: courier new,courier;"><span style="font-family: courier new,courier;"> + add_header Auth-Server <strong><span style="background-color: #00ff00;">192.0.2.222</span></strong>;<br /></span></span> + add_header Auth-Port <span style="background-color: #00ff00;"><strong>25</strong></span>;</span></span></p>
<p>it works well - I see the test incoming mail (I send to myself via 8025 port) and following output in the log (a lot of irrelevant messages are removed):</p>
<p>>>>>>>>>></p>
<p style="padding-left: 30px;"><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:04 [debug] 121280#128244: *1 smtp mail from:"mail FROM:<test@example.com>"</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">...</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:04 [debug] 121280#128244: *3 http request line: "GET /cgi-bin/nginxauth.cgi HTTP/1.0"</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:04 [debug] 121280#128244: *3 http uri: "/cgi-bin/nginxauth.cgi"</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:04 [debug] 121280#128244: *3 http args: ""</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:04 [debug] 121280#128244: *3 http exten: "cgi"</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:04 [debug] 121280#128244: *3 http process request header line</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:04 [debug] 121280#128244: *3 http header: "Host: localhost"</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:04 [debug] 121280#128244: *3 http header: "Auth-Method: none"</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:04 [debug] 121280#128244: *3 http header: "Auth-User: "</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:04 [debug] 121280#128244: *3 http header: "Auth-Pass: "</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:04 [debug] 121280#128244: *3 http header: "Auth-Protocol: smtp"</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:04 [debug] 121280#128244: *3 http header: "Auth-Login-Attempt: 1"</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:04 [debug] 121280#128244: *3 http header: "Client-IP: 127.0.0.1"</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:04 [debug] 121280#128244: *3 http header: "Client-Host: [UNAVAILABLE]"</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:04 [debug] 121280#128244: *3 http header: "Auth-SMTP-Helo: myhost.example.com"</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:04 [debug] 121280#128244: *3 http header: "Auth-SMTP-From: mail FROM:<test@example.com>"</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:04 [debug] 121280#128244: *3 http header: "Auth-SMTP-To: rcpt TO:<test@example.com>"</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:04 [debug] 121280#128244: *3 http header done</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:04 [debug] 121280#128244: *3 event timer del: 512: 1127939767</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:04 [debug] 121280#128244: *3 generic phase: 0</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:04 [debug] 121280#128244: *3 rewrite phase: 1</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:04 [debug] 121280#128244: *3 search through nested static locations of ""</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:04 [debug] 121280#128244: *3 test location: "/cgi-bin/nginxauth.cgi"</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:04 [debug] 121280#128244: *3 using configuration "/cgi-bin/nginxauth.cgi"</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:04 [debug] 121280#128244: *3 http cl:-1 max:1048576</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:04 [debug] 121280#128244: *3 rewrite phase: 3</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:04 [debug] 121280#128244: *3 http set discard body</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:04 [debug] 121280#128244: *3 HTTP/1.1 204 No Content</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">Server: nginx/1.17.4</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">Date: Fri, 14 Feb 2020 10:24:04 GMT</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">Connection: close</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">Auth-Status: OK</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">Auth-Server: 192.0.2.222</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">Auth-Port: 25</span><br /><br /><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:04 [debug] 121280#128244: *3 write new buf t:1 f:0 008AD6A0, pos 008AD6A0, size: 164 file: 0, size: 0</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:04 [debug] 121280#128244: *3 http write filter: l:1 f:0 s:164</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:04 [debug] 121280#128244: *3 http write filter limit 0</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:04 [debug] 121280#128244: *3 WSASend: fd:512, s:164</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:04 [debug] 121280#128244: *3 http write filter 00000000</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:04 [debug] 121280#128244: *3 http finalize request: 0, "/cgi-bin/nginxauth.cgi?" a:1, c:1</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:04 [debug] 121280#128244: *3 http request count:1 blk:0</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:04 [debug] 121280#128244: *3 http close request</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:04 [debug] 121280#128244: *3 http log handler</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:04 [debug] 121280#128244: *3 free: 008ACC50, unused: 1161</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:04 [debug] 121280#128244: *3 close http connection: 512</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:04 [debug] 121280#128244: *3 reusable connection: 0</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:04 [debug] 121280#128244: *3 free: 008AC848</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:04 [debug] 121280#128244: *3 free: 0039FDE0, unused: 28</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:04 [debug] 121280#128244: worker cycle</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:04 [debug] 121280#128244: *1 mail auth http read handler</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:04 [debug] 121280#128244: *1 WSARecv: fd:496 rc:0 164 of 1024</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:04 [debug] 121280#128244: *1 mail auth http process status line</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:04 [debug] 121280#128244: *1 mail auth http process headers</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:04 [debug] 121280#128244: *1 mail auth http header: "Server: nginx/1.17.4"</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:04 [debug] 121280#128244: *1 mail auth http header: "Date: Fri, 14 Feb 2020 10:24:04 GMT"</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:04 [debug] 121280#128244: *1 mail auth http header: "Connection: close"</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:04 [debug] 121280#128244: *1 mail auth http header: "Auth-Status: OK"</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:04 [debug] 121280#128244: *1 mail auth http header: "Auth-Server: 192.0.2.222"</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:04 [debug] 121280#128244: *1 mail auth http header: "Auth-Port: 25"</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:04 [debug] 121280#128244: *1 mail auth http header done</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:04 [debug] 121280#128244: *1 event timer del: 496: 1127939764</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:04 [debug] 121280#128244: *1 reusable connection: 0</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:04 [debug] 121280#128244: *1 free: 008AC040, unused: 196</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:04 [debug] 121280#128244: *1 stream socket 496</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:04 [debug] 121280#128244: *1 connect to 192.0.2.222:25, fd:496 #4</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:04 [debug] 121280#128244: *1 event timer add: 496: 60000:1127939769</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:04 [debug] 121280#128244: *1 malloc: 008AC040:4096</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:04 [debug] 121280#128244: worker cycle</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:04 [debug] 121280#128244: *1 post event 00897120</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:04 [debug] 121280#128244: posted event 00897120</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:04 [debug] 121280#128244: *1 delete posted event 00897120</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:04 [debug] 121280#128244: *1 mail proxy dummy handler</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:04 [debug] 121280#128244: worker cycle</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:04 [debug] 121280#128244: *1 mail proxy smtp auth handler</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:04 [debug] 121280#128244: *1 WSARecv: fd:496 rc:0 22 of 4096</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:04 [debug] 121280#128244: *1 mail proxy send ehlo</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:04 [debug] 121280#128244: *1 malloc: 0039FDE0:256</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:04 [debug] 121280#128244: *1 WSASend: fd:496, 0, 25 of 25</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:04 [debug] 121280#128244: worker cycle</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:05 [debug] 121280#128244: *1 mail proxy smtp auth handler</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:05 [debug] 121280#128244: *1 WSARecv: fd:496 rc:0 196 of 4096</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:05 [debug] 121280#128244: *1 mail proxy send mail from</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:05 [debug] 121280#128244: *1 WSASend: fd:496, 0, 47 of 47</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:05 [debug] 121280#128244: worker cycle</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:05 [debug] 121280#128244: *1 mail proxy smtp auth handler</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:05 [debug] 121280#128244: *1 WSARecv: fd:496 rc:0 60 of 4096</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:05 [debug] 121280#128244: *1 mail proxy send rcpt to</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:05 [debug] 121280#128244: *1 WSASend: fd:496, 0, 45 of 45</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:05 [debug] 121280#128244: worker cycle</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:05 [debug] 121280#128244: *1 mail proxy smtp auth handler</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:05 [debug] 121280#128244: *1 WSARecv: fd:496 rc:0 63 of 4096</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:05 [debug] 121280#128244: *1 event timer add: 492: 86400000:1214280441</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:05 [debug] 121280#128244: *1 event timer del: 496: 1127939769</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:05 [info] 121280#128244: *1 client logged in, client: 127.0.0.1, server: 0.0.0.0:8025</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:05 [debug] 121280#128244: *1 mail proxy handler: 1, #496 > #492</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:05 [debug] 121280#128244: *1 WSASend: fd:492, 0, 63 of 63</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:05 [debug] 121280#128244: *1 event timer: 492, old: 1214280441, new: 1214280441</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:05 [debug] 121280#128244: worker cycle</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:05 [debug] 121280#128244: *1 post event 008830C8</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:05 [debug] 121280#128244: posted event 008830C8</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:05 [debug] 121280#128244: *1 delete posted event 008830C8</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:05 [debug] 121280#128244: *1 mail proxy handler: 0, #492 > #496</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:05 [debug] 121280#128244: *1 WSARecv: fd:492 rc:0 6 of 4096</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:05 [debug] 121280#128244: *1 WSASend: fd:496, 0, 6 of 6</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:05 [debug] 121280#128244: *1 event timer: 492, old: 1214280441, new: 1214280441</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:05 [debug] 121280#128244: worker cycle</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:05 [debug] 121280#128244: *1 mail proxy handler: 0, #496 > #492</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:05 [debug] 121280#128244: *1 WSARecv: fd:496 rc:0 50 of 4096</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:05 [debug] 121280#128244: *1 WSASend: fd:492, 0, 50 of 50</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:05 [debug] 121280#128244: worker cycle</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:05 [debug] 121280#128244: *1 post event 008830C8</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:05 [debug] 121280#128244: posted event 008830C8</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:05 [debug] 121280#128244: *1 delete posted event 008830C8</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:05 [debug] 121280#128244: *1 mail proxy handler: 0, #492 > #496</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:05 [debug] 121280#128244: *1 WSARecv: fd:492 rc:0 170 of 4096</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:05 [debug] 121280#128244: *1 WSASend: fd:496, 0, 170 of 170</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:05 [debug] 121280#128244: *1 event timer: 492, old: 1214280441, new: 1214280535</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:05 [debug] 121280#128244: worker cycle</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:05 [debug] 121280#128244: *1 mail proxy handler: 0, #496 > #492</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:05 [debug] 121280#128244: *1 WSARecv: fd:496 rc:0 56 of 4096</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:05 [debug] 121280#128244: *1 WSASend: fd:492, 0, 56 of 56</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">2020/02/14 11:24:05 [debug] 121280#128244: worker cycle</span><br /><span style="font-size: xx-small; font-family: courier new,courier;">...</span></p>
<p><<<<<<<<<</p>
<p>Regards,<br />Sergey</p>
<p>13.02.2020 22:45, Yury Shpakov wrote:</p>
<blockquote type="cite" style="padding-left:5px; border-left:#1010ff 2px solid; margin-left:5px"><!-- html ignored --> <!-- head ignored --><!-- meta ignored -->
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: #000000;">Hi Sergey,</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: #000000;"> </div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: #000000;"> </div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: #000000;">I reconfigured the config file as follows:</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: #000000;"> </div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: #000000;">=== === ===</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: #000000;">
<div>#user nobody;</div>
<div>worker_processes 1;</div>
<div> </div>
<div>#error_log logs/error.log;</div>
<div>#error_log logs/error.log notice;</div>
<div>#error_log logs/error.log info;</div>
<div> </div>
<div>#pid logs/nginx.pid;</div>
<div> </div>
<div> </div>
<div>events {</div>
<div> worker_connections 1024;</div>
<div>}</div>
<div> </div>
<div> </div>
<div>mail {</div>
<div> server_name localhost;</div>
<div> auth_http localhost:9000/cgi-bin/nginxauth.cgi;</div>
<div># auth_http none;</div>
<div> </div>
<div> smtp_auth none;</div>
<div># smtp_auth login plain cram-md5;</div>
<div># smtp_capabilities "SIZE 10485760" ENHANCEDSTATUSCODES 8BITMIME DSN;</div>
<div> xclient off;</div>
<div> </div>
<div> server {</div>
<div> listen 8025;</div>
<div> protocol smtp;</div>
<div><span style="font-family: Calibri, Helvetica, sans-serif; background-color: #ffffff; display: inline !important;"> <span> </span></span>proxy on;</div>
<div><span style="font-family: Calibri, Helvetica, sans-serif; background-color: #ffffff; display: inline !important;"> <span> </span></span>proxy_pass_error_message on;</div>
<div> }</div>
<div>}</div>
<div> </div>
<div>http {</div>
<div> server {</div>
<div> listen 9000;</div>
<div> </div>
<div> location /cgi-bin/nginxauth.cgi {</div>
<div><span style="font-family: Calibri, Helvetica, sans-serif; background-color: #ffffff; display: inline !important;"> <span> <span style="font-family: Calibri, Helvetica, sans-serif; background-color: #ffffff; display: inline !important;"> <span> </span></span></span></span>add_header Auth-Status OK;</div>
<div><span style="font-family: Calibri, Helvetica, sans-serif; background-color: #ffffff; display: inline !important;"> <span> <span style="font-family: Calibri, Helvetica, sans-serif; background-color: #ffffff; display: inline !important;"> <span> </span></span></span></span>add_header Auth-Server 127.0.0.2; # backend ip</div>
<div><span style="font-family: Calibri, Helvetica, sans-serif; background-color: #ffffff; display: inline !important;"> <span> <span style="font-family: Calibri, Helvetica, sans-serif; background-color: #ffffff; display: inline !important;"> <span> </span></span></span></span>add_header Auth-Port 143; # backend port</div>
<div><span style="font-family: Calibri, Helvetica, sans-serif; background-color: #ffffff; display: inline !important;"> <span> <span style="font-family: Calibri, Helvetica, sans-serif; background-color: #ffffff; display: inline !important;"> <span> </span></span></span></span>return 204;</div>
<div> }</div>
<div> }</div>
<div>}</div>
<div><span style="color: #000000; font-family: Calibri, Helvetica, sans-serif; font-size: 12pt;">=== === ===</span></div>
<span></span></div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: #000000;"> </div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: #000000;">And now it's responding on port 9000 as expected:</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: #000000;"> </div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: #000000;">=== === ===</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: #000000;"><span>C:\WINDOWS\system32>curl -H "Auth-Method: plain" -H "Auth-User: user" -H "Auth-Pass: pwd" -H "Auth-Protocol: imap" -H "Auth-Login-Attempt: 1" -i http://127.0.0.1:9000/cgi-bin/nginxauth.cgi<br /> </span>
<div>HTTP/1.1 204 No Content</div>
<div>Server: nginx/1.17.9</div>
<div>Date: Thu, 13 Feb 2020 21:30:54 GMT</div>
<div>Connection: keep-alive</div>
<div>Auth-Status: OK</div>
<div>Auth-Server: 127.0.0.2</div>
<span>Auth-Port: 143</span></div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: #000000;">=== === ===</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: #000000;"> </div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: #000000;">However I'm still experiencing the same issue (in log file):</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: #000000;"> </div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: #000000;">=== === ===</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: #000000;"><span>2020/02/13 16:29:24 [notice] 35048#26192: signal process started<br /> </span>
<div>2020/02/13 16:29:34 [error] 31732#22720: *1 WSASend() failed (10057: A request to send or receive data was disallowed because the socket is not connected and (when sending on a datagram socket using a sendto call) no address was supplied) while in http auth state, client: 127.0.0.1, server: 0.0.0.0:8025</div>
<span></span>=== === ===</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: #000000;"> </div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: #000000;">Tried under both admin and regular user.</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: #000000;"> </div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: #000000;">Any further ideas how to get it fixed please?</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: #000000;"> </div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: #000000;"> </div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: #000000;">Thank you,</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: #000000;">Yury</div>
<div id="appendonsend"> </div>
<hr style="display: inline-block; width: 98%;" />
<div id="divRplyFwdMsg" dir="ltr"><span style="font-size: 11pt; color: #000000; font-family: Calibri,sans-serif;"><strong>From:</strong> Sergey Brester <serg.brester@sebres.de><br /> <strong>Sent:</strong> Wednesday, February 12, 2020 1:51 PM<br /> <strong>To:</strong> Yury Shpakov <yshpakov@hotmail.com><br /> <strong>Cc:</strong> nginx-devel@nginx.org <nginx-devel@nginx.org><br /> <strong>Subject:</strong> Re: nginx for Windows - WSASend() socket error 10057</span>
<div> </div>
</div>
<div style="font-size: 10pt; font-family: Verdana,Geneva,sans-serif;">
<p>I answered inline...</p>
<p>12.02.2020 18:59, Yury Shpakov wrote:</p>
<blockquote style="padding-left: 5px; border-left: #1010ff 2px solid; margin-left: 5px;">
<div style="font-family: Calibri,Helvetica,sans-serif; font-size: 12pt; color: #000000;">Hi Sergey,</div>
<div style="font-family: Calibri,Helvetica,sans-serif; font-size: 12pt; color: #000000;"> </div>
<div style="font-family: Calibri,Helvetica,sans-serif; font-size: 12pt; color: #000000;"> </div>
<div style="font-family: Calibri,Helvetica,sans-serif; font-size: 12pt; color: #000000;">Thank you for you response.</div>
<div style="font-family: Calibri,Helvetica,sans-serif; font-size: 12pt; color: #000000;"> </div>
<div style="font-family: Calibri,Helvetica,sans-serif; font-size: 12pt; color: #000000;">I tried <span style="color: #201f1e; font-family: Verdana,Geneva,sans-serif; font-size: 13.3333px; background-color: #ffffff; display: inline!important;">netstat /nabo and I don't see any reference to port 9000 at all.</span></div>
<div style="font-family: Calibri,Helvetica,sans-serif; font-size: 12pt; color: #000000;"><span style="color: #201f1e; font-family: Verdana,Geneva,sans-serif; font-size: 13.3333px; background-color: #ffffff; display: inline!important;">So a problem is to make nginx to listen on port 9000 (as server)?</span></div>
<div style="font-family: Calibri,Helvetica,sans-serif; font-size: 12pt; color: #000000;"><span style="color: #201f1e; font-family: Verdana,Geneva,sans-serif; font-size: 13.3333px; background-color: #ffffff; display: inline!important;">Or nginx is not listening on port 9000 but rather sending requests to port 9000 (as client)?</span></div>
</blockquote>
<div style="font-family: Calibri,Helvetica,sans-serif; font-size: 12pt; color: #000000;"><span style="color: #0000ff;">With setting of `auth_http`, you are defining an URL to the service responsible for authentication (and upstream choice).</span></div>
<div style="font-family: Calibri,Helvetica,sans-serif; font-size: 12pt; color: #000000;"><span style="color: #0000ff;">Of course then you should have something that would response to the auth-requests (your own upstream, or some nginx location, or some "foreign" http-server).</span></div>
<div style="font-family: Calibri,Helvetica,sans-serif; font-size: 12pt; color: #000000;"> </div>
<div style="font-family: Calibri,Helvetica,sans-serif; font-size: 12pt; color: #000000;"><span style="color: #0000ff;">See</span> <a href="https://docs.nginx.com/nginx/admin-guide/mail-proxy/mail-proxy/"> https://docs.nginx.com/nginx/admin-guide/mail-proxy/mail-proxy/</a> <span style="color: #0000ff;"> for more examples.</span></div>
<blockquote style="padding-left: 5px; border-left: #1010ff 2px solid; margin-left: 5px;">
<div style="font-family: Calibri,Helvetica,sans-serif; font-size: 12pt; color: #000000;">Maybe it's easier not to use auth_http at all? I was trying to remove it from configuration file but nginx was not happy.</div>
</blockquote>
<p><span style="color: #0000ff;">I have my own auth-module so I don't know how it can be solved in stock-nginx without this directive.</span></p>
<p><span style="color: #0000ff;">Take a look here - <a href="https://serverfault.com/questions/594962/nginx-understanding-the-purpose-of-auth-http-imap-proxy"> https://serverfault.com/questions/594962/nginx-understanding-the-purpose-of-auth-http-imap-proxy</a> - you can use some nginx location (and internal URL to same nginx instance) to specify that.<br /> </span></p>
<p><span style="color: #0000ff;">Anyway it is recommended to use some auth (on nginx side), because it'd preserve the resources of mail-servers, allow you to authenticate email clients with same user/password for all mail-servers (smtp, imap, pop3, etc) as well as the same user/pwd as for some other http-services. And it is used to choose an upstream server (if multiple) for the email processing.</span></p>
<blockquote style="padding-left: 5px; border-left: #1010ff 2px solid; margin-left: 5px;">
<div style="font-family: Calibri,Helvetica,sans-serif; font-size: 12pt; color: #000000;">At this point I don't need any authentication. I was told by my boss to use nginx for load testing of our service sending emails (SMTP client). I've got some SMTP Server and nginx would be used as SMTP proxy because it allows to set up delays.</div>
</blockquote>
<div style="font-family: Calibri,Helvetica,sans-serif; font-size: 12pt; color: #000000;"><span style="color: #0000ff;">Well, an auth request to some nginx-location would allow you to set up delays even on authentication phase.</span></div>
<blockquote style="padding-left: 5px; border-left: #1010ff 2px solid; margin-left: 5px;">
<div style="font-family: Calibri,Helvetica,sans-serif; font-size: 12pt; color: #000000;">And take into account that I REMOVED "--with-http_ssl_module" from parameters when I was building nginx.</div>
<div style="font-family: Calibri,Helvetica,sans-serif; font-size: 12pt; color: #000000;"> </div>
<div style="font-family: Calibri,Helvetica,sans-serif; font-size: 12pt; color: #000000;">And you advised to download some nginx.exe files but I believe they were built without "--with-mail" parameter (which I need).</div>
</blockquote>
<div style="font-family: Calibri,Helvetica,sans-serif; font-size: 12pt; color: #000000;"><span style="color: #0000ff;">Although, it was compiled with "--with-mail" (you can see all parameters</span> <a href="https://github.com/sebres/nginx/releases/tag/release-1.13.0">in provided GH-link</a><span style="color: #0000ff;">)</span></div>
<div style="font-family: Calibri,Helvetica,sans-serif; font-size: 12pt; color: #000000;"><span style="color: #0000ff;">But it would not help, because basically your issue seems to be the configuration (not the nginx.exe).</span></div>
<blockquote style="padding-left: 5px; border-left: #1010ff 2px solid; margin-left: 5px;">
<div style="font-family: Calibri,Helvetica,sans-serif; font-size: 12pt; color: #000000;"> </div>
<div style="font-family: Calibri,Helvetica,sans-serif; font-size: 12pt; color: #000000;">Thank you,</div>
<div style="font-family: Calibri,Helvetica,sans-serif; font-size: 12pt; color: #000000;">Yury</div>
<div id="x_appendonsend"> </div>
<hr style="display: inline-block; width: 98%;" />
<div id="x_divRplyFwdMsg" dir="ltr"><span style="font-size: 11pt; color: #000000; font-family: Calibri,sans-serif;"><strong>From:</strong> Sergey Brester <serg.brester@sebres.de><br /> <strong>Sent:</strong> Wednesday, February 12, 2020 7:38 AM<br /> <strong>To:</strong> nginx-devel@nginx.org <nginx-devel@nginx.org><br /> <strong>Cc:</strong> Yury Shpakov <yshpakov@hotmail.com><br /> <strong>Subject:</strong> Re: nginx for Windows - WSASend() socket error 10057</span></div>
<div style="font-size: 10pt; font-family: Verdana,Geneva,sans-serif;">
<p>It looks like your service defined in auth_http doesn't answer (or no listener on 127.0.0.1 port 9000?)...</p>
<p>try netstat (in cmd as admin):</p>
<p style="padding-left: 30px;">netstat /nabo<br /> netstat /nabo | grep -A 1 ":9000\b"</p>
<p>and check whether the listener on port 9000 is bound to 127.0.0.1 (or it is 0.0.0.0 only?) and it is the process you expect to see there (can be "reserved" by some other windows-service).</p>
<p>additionally try to telnet or curl it:</p>
<p style="padding-left: 30px;">curl -H "Auth-Method: plain" -H "Auth-User: user" -H "Auth-Pass: pwd" -H "Auth-Protocol: imap" -H "Auth-Login-Attempt: 1" -i http://127.0.0.1:9000/cgi-bin/nginxauth.cgi</p>
<p>if it does not answer, make another attempt by replace 127.0.0.1 with 0.0.0.0 (or a host-name).</p>
<p>If it answers - see whether it is the expected response (some examples of good and bad responses are described in <a href="http://nginx.org/en/docs/mail/ngx_mail_auth_http_module.html">http://nginx.org/en/docs/mail/ngx_mail_auth_http_module.html</a>).</p>
<p>But I guess if WSASend fails, it would probably (unexpected) reject the connection during the send (or even connect) process.<br /> It can be also invalid (unexpected) content-length in keep-alive connect to auth-upstream - so send but still receive is expected (or vice versa).</p>
<p>Also follow this forum topic addressing similar issue: <a href="https://forum.nginx.org/read.php?2,257206,257207#msg-257207"> https://forum.nginx.org/read.php?2,257206,257207#msg-257207</a></p>
<p>Anyway it doesn't look to me like an issue of nginx (regardless windows or not), but you can also try some other ready build (for example on my <a href="https://github.com/sebres/nginx/releases/tag/release-1.13.0">GH</a> - <a href="https://github.com/sebres/nginx/files/2246440/nginx.zip"> nginx.zip</a>, where it works well).</p>
<p>Regards,<br /> Sergey</p>
<p>12.02.2020 03:01, Yury Shpakov wrote:</p>
<blockquote style="padding-left: 5px; border-left: #1010ff 2px solid; margin-left: 5px;">
<div style="font-family: Calibri,Helvetica,sans-serif; font-size: 12pt; color: #000000;"><span style="color: #000000; font-family: Calibri,Helvetica,sans-serif; font-size: 12pt;">Hi there,</span></div>
<div>
<div>
<div style="font-family: Calibri,Helvetica,sans-serif; font-size: 12pt; color: #000000;">Trying to make nginx work as SMTP server and/or SMTP proxy. Done everything according to:</div>
<div style="font-family: Calibri,Helvetica,sans-serif; font-size: 12pt; color: #000000;"><a href="http://nginx.org/en/docs/howto_build_on_win32.html">http://nginx.org/en/docs/howto_build_on_win32.html</a></div>
<div style="font-family: Calibri,Helvetica,sans-serif; font-size: 12pt; color: #000000;">But excluded (don't care about SSL at this point so don't want to install/configure Perl now):</div>
<div style="font-family: Calibri,Helvetica,sans-serif; font-size: 12pt; color: #000000;"><span> --with-openssl=objs/lib/openssl-master \<br /> </span>
<div> --with-openssl-opt=no-asm \</div>
<div> --with-http_ssl_module \</div>
</div>
<div style="font-family: Calibri,Helvetica,sans-serif; font-size: 12pt; color: #000000;">And added:</div>
<div style="font-family: Calibri,Helvetica,sans-serif; font-size: 12pt; color: #000000;"><span> --with-mail<br /> </span></div>
<div style="font-family: Calibri,Helvetica,sans-serif; font-size: 12pt; color: #000000;">nmake was successful and nginx.exe was created.</div>
<div style="font-family: Calibri,Helvetica,sans-serif; font-size: 12pt; color: #000000;">However nginx.exe keeps failing with the error:</div>
<div style="font-family: Calibri,Helvetica,sans-serif; font-size: 12pt; color: #000000;">WSASend() failed (10057: A request to send or receive data was disallowed because the socket is not connected and (when sending on a datagram socket using a sendto call) no address was supplied) while in http auth state, client: 127.0.0.1, server: 0.0.0.0:8025</div>
<div style="font-family: Calibri,Helvetica,sans-serif; font-size: 12pt; color: #000000;">Windows API says the following about this error:</div>
<div style="font-family: Calibri,Helvetica,sans-serif; font-size: 12pt; color: #000000;">
<table style="border-collapse: collapse; border-spacing: 0px; table-layout: auto; width: 683px; font-size: 0.875rem; color: #171717; font-family: 'Segoe UI',SegoeUI,'Segoe WP','Helvetica Neue',Helvetica,Tahoma,Arial,sans-serif; background-color: #ffffff;">
<tbody>
<tr>
<td style="padding: 0.75rem 1rem; text-align: left; display: table-cell; line-height: 1.5; vertical-align: top; border-right: 0px solid; border-left: 0px solid; border-bottom: 0px solid; border-top-style: solid;"><dl style="margin: 0px;"><dt style="margin: 0px;"><strong style="font-weight: bolder;">WSAENOTCONN</strong></dt><dt style="margin: 0px;">10057</dt></dl></td>
<td style="padding: 0.75rem 1rem; text-align: left; display: table-cell; line-height: 1.5; vertical-align: top; border-right: 0px solid; border-left: 0px solid; border-bottom: 0px solid; border-top-style: solid;"><dl style="margin: 0px;"><dt style="margin: 0px;">Socket is not connected.</dt><dd style="margin: 0px;">A request to send or receive data was disallowed because the socket is not connected and (when sending on a datagram socket using<span> </span><a style="outline: 0px;" href="https://docs.microsoft.com/en-us/windows/desktop/api/winsock/nf-winsock-sendto"><strong style="font-weight: bolder;">sendto</strong></a>) no address was supplied. Any other type of operation might also return this error—for example,<span> </span><a style="outline: 0px;" href="https://docs.microsoft.com/en-us/windows/desktop/api/winsock/nf-winsock-setsockopt"><strong style="font-weight: bolder;">setsockopt</strong></a><span> </span>setting<span> </span><a style="outline: 0px;" href="https://docs.microsoft.com/en-us/windows/desktop/winsock/so-keepalive"><strong style="font-weight: bolder;">SO_KEEPALIVE</strong></a><span> </span>if the connection has been reset.</dd></dl></td>
</tr>
</tbody>
</table>
<a id="LPlnk497731" href="https://docs.microsoft.com/en-us/windows/win32/winsock/windows-sockets-error-codes-2">https://docs.microsoft.com/en-us/windows/win32/winsock/windows-sockets-error-codes-2</a><br />
<div id="LPBorder_GTaHR0cHM6Ly9kb2NzLm1pY3Jvc29mdC5jb20vZW4tdXMvd2luZG93cy93aW4zMi93aW5zb2NrL3dpbmRvd3Mtc29ja2V0cy1lcnJvci1jb2Rlcy0y" class="x_x_LPBorder170815" style="width: 100%; margin-top: 16px; margin-bottom: 16px; max-width: 800px; min-width: 424px;">
<table id="LPContainer170815" style="padding: 12px 36px 12px 12px; width: 100%; border-width: 1px; border-style: solid; border-color: #c8c8c8; border-radius: 2px;">
<tbody>
<tr style="border-spacing: 0px;" valign="top">
<td style="width: 100%;">
<div id="LPTitle170815" style="font-size: 21px; font-weight: 300; margin-right: 8px; font-family: wf_segoe-ui_light,'Segoe UI Light','Segoe WP Light','Segoe UI','Segoe WP',Tahoma,Arial,sans-serif; margin-bottom: 12px;"><a id="LPUrlAnchor170815" style="text-decoration: none;" href="https://docs.microsoft.com/en-us/windows/win32/winsock/windows-sockets-error-codes-2">Windows Sockets Error Codes (Winsock2.h) - Win32 apps | Microsoft Docs</a></div>
<div id="LPDescription170815" style="font-size: 14px; max-height: 100px; color: #666666; font-family: wf_segoe-ui_normal,'Segoe UI','Segoe WP',Tahoma,Arial,sans-serif; margin-bottom: 12px; margin-right: 8px; overflow: hidden;">Return code/value Description; WSA_INVALID_HANDLE 6: Specified event object handle is invalid. An application attempts to use an event object, but the specified handle is not valid.</div>
<div id="LPMetadata170815" style="font-size: 14px; font-weight: 400; color: #a6a6a6; font-family: wf_segoe-ui_normal,'Segoe UI','Segoe WP',Tahoma,Arial,sans-serif;">docs.microsoft.com</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div style="font-family: Calibri,Helvetica,sans-serif; font-size: 12pt; color: #000000;">Managed to debug your code in VS 2010 a little bit but it's brutal C so it's hard to figure your code out. And this debugger doesn't show you any local variables values.</div>
<div style="font-family: Calibri,Helvetica,sans-serif; font-size: 12pt; color: #000000;">Any recommendation for me to make it work?</div>
<div style="font-family: Calibri,Helvetica,sans-serif; font-size: 12pt; color: #000000;">Tried to play with config (commenting/uncommenting):</div>
<div style="font-family: Calibri,Helvetica,sans-serif; font-size: 12pt; color: #000000;">
<div>#user nobody;</div>
<div>worker_processes 1;</div>
<div>#error_log logs/error.log;</div>
<div>#error_log logs/error.log notice;</div>
<div>#error_log logs/error.log info;</div>
<div>#pid logs/nginx.pid;</div>
<div>events {</div>
<div> worker_connections 1024;</div>
<div>}</div>
<div>mail {</div>
<div> server_name localhost;</div>
<div> auth_http localhost:9000/cgi-bin/nginxauth.cgi;</div>
<div># auth_http none;</div>
<div> smtp_auth none;</div>
<div># smtp_auth login plain cram-md5;</div>
<div># smtp_capabilities "SIZE 10485760" ENHANCEDSTATUSCODES 8BITMIME DSN;</div>
<div> xclient off;</div>
<div> server {</div>
<div> listen 8025;</div>
<div> protocol smtp;</div>
<div><span style="font-family: Calibri,Helvetica,sans-serif; background-color: #ffffff; display: inline!important;"> <span> </span></span>proxy on;</div>
<div><span style="font-family: Calibri,Helvetica,sans-serif; background-color: #ffffff; display: inline!important;"> <span> </span></span>proxy_pass_error_message on;</div>
<div> }</div>
<div>}</div>
Tried both under a regular user and under admin. Tried on 25, 1025 and 8025 ports.</div>
<div style="font-family: Calibri,Helvetica,sans-serif; font-size: 12pt; color: #000000;">Thank you,</div>
<div style="font-family: Calibri,Helvetica,sans-serif; font-size: 12pt; color: #000000;">Yury</div>
</div>
</div>
<br />
<pre>_______________________________________________
nginx-devel mailing list
<a href="mailto:nginx-devel@nginx.org">nginx-devel@nginx.org</a><a href="http://mailman.nginx.org/mailman/listinfo/nginx-devel">http://mailman.nginx.org/mailman/listinfo/nginx-devel</a></pre>
</blockquote>
</div>
</blockquote>
</div>
</blockquote>
</body></html>