comparison mail_proxy_protocol.t @ 1660:068c30e9d2c6

Tests: smtp tests with proxy protocol to backend.
author Sergey Kandaurov <pluknet@nginx.com>
date Fri, 05 Mar 2021 19:18:52 +0300
parents d1c4059e1e72
children 74986ebee2fd
comparison
equal deleted inserted replaced
1659:d1c4059e1e72 1660:068c30e9d2c6
38 } 38 }
39 39
40 mail { 40 mail {
41 proxy_pass_error_message on; 41 proxy_pass_error_message on;
42 proxy_smtp_auth on; 42 proxy_smtp_auth on;
43 proxy_protocol on;
43 auth_http http://127.0.0.1:8080/mail/auth; 44 auth_http http://127.0.0.1:8080/mail/auth;
44 smtp_auth login plain; 45 smtp_auth login plain;
45 46
46 server { 47 server {
47 listen 127.0.0.1:8025 proxy_protocol; 48 listen 127.0.0.1:8025 proxy_protocol;
88 } 89 }
89 90
90 EOF 91 EOF
91 92
92 $t->run_daemon(\&Test::Nginx::SMTP::smtp_test_daemon); 93 $t->run_daemon(\&Test::Nginx::SMTP::smtp_test_daemon);
93 $t->try_run('no proxy_protocol')->plan(6); 94 $t->try_run('no proxy_protocol')->plan(8);
94 95
95 $t->waitforsocket('127.0.0.1:' . port(8026)); 96 $t->waitforsocket('127.0.0.1:' . port(8026));
96 97
97 ############################################################################### 98 ###############################################################################
98 99
106 $s->check(qr/^250 /, "ehlo with proxy_protocol"); 107 $s->check(qr/^250 /, "ehlo with proxy_protocol");
107 108
108 $s->send('AUTH PLAIN ' . encode_base64("\0test\@example.com\0secret", '')); 109 $s->send('AUTH PLAIN ' . encode_base64("\0test\@example.com\0secret", ''));
109 $s->authok('auth with proxy_protocol'); 110 $s->authok('auth with proxy_protocol');
110 111
112 $s->send('XPROXY');
113 $s->check(qr/^211 PROXY TCP4 127.0.0.1 127.0.0.1 \d+ \d+/,
114 'proxy protocol to backend');
115
111 # connection with PROXY protocol and set_realip_from 116 # connection with PROXY protocol and set_realip_from
112 117
113 $s = Test::Nginx::SMTP->new(PeerAddr => '127.0.0.1:' . port(8027)); 118 $s = Test::Nginx::SMTP->new(PeerAddr => '127.0.0.1:' . port(8027));
114 119
115 $s->send('PROXY TCP4 192.0.2.1 192.0.2.2 123 5678'); 120 $s->send('PROXY TCP4 192.0.2.1 192.0.2.2 123 5678');
119 $s->check(qr/^250 /, "ehlo with proxy_protocol and realip"); 124 $s->check(qr/^250 /, "ehlo with proxy_protocol and realip");
120 125
121 $s->send('AUTH PLAIN ' . encode_base64("\0test\@example.com\0secret", '')); 126 $s->send('AUTH PLAIN ' . encode_base64("\0test\@example.com\0secret", ''));
122 $s->authok('auth with proxy_protocol and realip'); 127 $s->authok('auth with proxy_protocol and realip');
123 128
129 $s->send('XPROXY');
130 $s->check(qr/^211 PROXY TCP4 192.0.2.1 127.0.0.1 \d+ \d+/,
131 'proxy_protocol to backend and realip');
132
124 ############################################################################### 133 ###############################################################################