8

I have nginx setup that passes all request to nodejs, however I want to modify request body in nginx before passing it to nodejs. Like if body has http://www.example.com then replace it with https://www.example.com

Here is my nginx configuration:

location / {
    proxy_pass  http://127.0.0.1:8008;
    proxy_redirect off;
    proxy_set_header Host $host ;
    proxy_set_header X-Real-IP $remote_addr ;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for ;
    proxy_set_header X-Forwarded-Proto https ;
}
Sadiq Khoja
  • 522
  • 1
  • 5
  • 23
  • 1
    So you want to modify the POST request's body? Not a suggested thing to do as such because it would mean reading the whole body at your server level and then make modification and pass it down. And of course you will need to use lua for the same – Tarun Lalwani Mar 31 '18 at 06:33
  • https://stackoverflow.com/questions/22788236/how-can-i-manipulate-the-json-body-of-a-post-request-using-nginx-and-lua – Tarun Lalwani Mar 31 '18 at 06:38
  • Possible duplicate of [How can I manipulate the JSON body of a POST request using Nginx and Lua?](https://stackoverflow.com/questions/22788236/how-can-i-manipulate-the-json-body-of-a-post-request-using-nginx-and-lua) – Michael - sqlbot Mar 31 '18 at 21:37

0 Answers0