Skip to content

The following example is to rewrite incoming requests by adding some additional data then send a new request to the destination.

License

Notifications You must be signed in to change notification settings

Gershon-A/nginx-lua-rewrite-request

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Test

Reverse proxy

cd nginx-lua-request-capture
docker-compose -f docker-compose.yml up -d

logger

cd logger
docker-compose -f docker-compose-loger.yml up -d

Send request

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" }'

How Tested:

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\"}"

About

The following example is to rewrite incoming requests by adding some additional data then send a new request to the destination.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published