cd nginx-lua-request-capture
docker-compose -f docker-compose.yml up -d
cd logger
docker-compose -f docker-compose-loger.yml up -d
curl -i http://localhost:8082/ -H 'content-type: application/json' -d '{ "level":"INFO", "source":"Gershon", "message":"Received response 404", "client_secret":"secret", "user_key":"my_key" }'
curl -i http://localhost:8082/ -H 'content-type: application/json' -d '{ "level":"INFO", "source":"Gershon", "message":"Received response 404", "client_secret":"secret", "user_key":"my_key" }'
http://localhost:8082
- nginx that acts as a reverse proxy to another nginx that acts as logger
http://localhost:8082
nginx rewrite body request and append additional data "client_ip":"172.19.0.1"
before sending to destination (logger
)
The request received at the end (logger
):
docker logs -f logger_nginx_1
"body":"{\"user_key\":\"my_key\",\"client_ip\":\"172.19.0.1\",\"message\":\"Received response 404\",\"level\":\"INFO\",\"source\":\"Gershon\",\"client_secret\":\"secret\"}"