Unit test for proxy_protocol
Sergey Kandaurov
pluknet at nginx.com
Tue Sep 21 09:43:14 UTC 2021
> On 21 Sep 2021, at 07:56, Greeshma A <greeshma.avadhootha at gmail.com> wrote:
>
> I am trying to test the following config :
> For proxy_protocol I have made changes in the nginx source code to support variable input parameter as well.
> Im writing unit tests for this. However, Im not sure how to configure the map directive. The variable $ssl_preread_server_nameis wrong. I need to give the destination address and port. What would I have to give in the key part of the map definition?
> ie something like
> map $remote_addr:$remote_port $proxy_state {
> # conditions
> }
For destination you'd need $server_addr / $server_port variables.
See stream_map.t as a rough example.
You might also want to look at these variables:
$proxy_protocol_server_addr / $proxy_protocol_server_port.
All of them described on this page:
http://nginx.org/en/docs/stream/ngx_stream_core_module.html
>
> stream {
> %%TEST_GLOBALS_STREAM%%
>
> map $ssl_preread_server_name $proxy_state{
> default off;
> 127.0.0.1:8084 on;
> }
>
> server {
> listen 127.0.0.1:8080;
> proxy_pass 127.0.0.1:8081;
> proxy_protocol on;
> }
>
> server {
> listen 127.0.0.1:8082;
> proxy_pass 127.0.0.1:8081;
> proxy_protocol off;
> }
>
> server {
> listen 127.0.0.1:8083;
> proxy_pass 127.0.0.1:8081;
> proxy_protocol $proxy_state;
> }
>
> server {
> listen 127.0.0.1:8084;
> proxy_pass 127.0.0.1:8081;
> proxy_protocol $proxy_state;
> }
> }
> <nginx_proxy_protocol.txt>_______________________________________________
> nginx-devel mailing list
> nginx-devel at nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx-devel
--
Sergey Kandaurov
More information about the nginx-devel
mailing list