Score:0

nginx mirror traffic and process with lua script

ng flag

I want to proxy requests to the backend_old server and process them with lua script. My nginx config:

upstream backend_old {
        server backend_old.com:443;
}
 
server {
        listen 80 default_server;
        listen [::]:80 default_server;
 
        location = /mypath {
                mirror /mirror;
                mirror_request_body on;
                proxy_pass https://backend_old/1.0/path;
       }

        location = /mirror {
                internal;
                access_by_lua_block {
                        ngx.exit(ngx.HTTP_FORBIDDEN)
                }
       }
}

I see data request completed to old_backend: [11/Jan/2022:23:59:32 +0000] 127.0.0.6 - - - _ to: 184.72.39.201:443: POST /mypath HTTP/1.1 upstream_response_time 0.088 msec 1641945572.657 request_time 0.087 enter code here

But mirror fails with: 2022/01/11 23:59:32 [error] 481#481: *158 open() "/usr/local/openresty/nginx/html/mirror" failed (2: No such file or directory), client: 127.0.0.6, server: _, request: "POST /mypath HTTP/1.1", subrequest: "/mirror", host: myhost

any ideas on how I can configure /mirror location properly?

us flag
The documentation shows only `proxy_pass` as a target for `mirror`. Most likely you cannot process the mirror requests with lua.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.