Score:0

Nginx reverse proxy removes contents from multipart/formdata

se flag

I have two nodejs apps sitting behind an nginx reverse proxy. Here is my nginx configuration,

#main_api 
location / {
      proxy_pass http://localhost:3000;
    }

#chat_api
location /socket.io/ {
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header Host $http_host;
      proxy_set_header X-NginX-Proxy false;
      proxy_pass http://localhost:3001/socket.io/;
      proxy_redirect off;
      proxy_http_version 1.1;
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection "upgrade";
    }
....
//ssl stuffs

I can send normal HTTP requests with JSON body. But when I send multipart/formdata, nginx removes fields from my request body. My request contains few text fields and a file. If I access HTTPS version of my API url, only the file gets ignored by nginx, but when the HTTP version is accessed, the text fields also get ignored, and my POST request gets converted into GET request.

Here is my nginx access log,

103.160.233.51 - - [28/May/2022:07:23:51 +0000] "POST /api/files/upload_dp HTTP/1.1" 500 26 "-" "PostmanRuntime/7.29.0"
103.160.233.51 - - [28/May/2022:07:24:04 +0000] "POST /api/files/upload_dp HTTP/1.1" 301 178 "-" "PostmanRuntime/7.29.0"
103.160.233.51 - - [28/May/2022:07:24:04 +0000] "GET /api/files/upload_dp HTTP/1.1" 401 43 "http://myapiurl.com/api/files/upload_dp" "PostmanRuntime/7.29.0"

And the nginx error log is empty.

What nginx config option am I missing?

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.