-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Nginx prepends post request body with response data #951
Comments
Log upstream related metrics (at least address, time, status and length ) and compare those with what you have in nginx response. But overall, this question has nothing to do with docker image of nginx, really. |
As per your instructions, I have logged upstream response length and added information below. Another thing I want to let you know that when I try this whole setup without docker with same versions of nginx and php on another debian vps, it works fine without any issue. upstream related metrics nginx response size in postman
nginx/default.conf
docker-compose.yml
|
@faizangulzar first of all, I don't see any matching numbers (body length reported by postman should match something in nginx logs, I suppose). Secondly, I don't know what was the request and response, so it's difficult for me to tell where the problem is. What i meant is that upstream_response_length is response body length. And you can debug the problem further youself. Please, try similar approach: you can start a shell in the container with If upstream_response_length doesn't match the |
It's also worth mentioning that it's not that easy to make nginx prepend request body to a reply. It is possible but requires some fiddling with configuration. So it's probably not an nginx problem, really |
I have set up my Laravel API with Docker(version: 26.1.1), Nginx(image: nginx:stable-alpine), and PHP(image: php:7.4-fpm-alpine) on Debian vps.
For a few days I'm struggling with a strange problem: The result I receive for my API request does not only include the valid response, but also the parameters that I send along with the post request;
Request:
{ "email": "[email protected]", "password": "xxxxxxx" }
Response:
{ "email": "[email protected]", "password": "xxxxxxx" }{ "token": "xxxxxxxxxxxxxxxxxxxxxxxxxx", "type": "xxxxxxxx" }
This response does not come with a content-type: application/json but as text/html. It seems like the post request body is prepended to the response data of my API. This results in a JSON parse error on my client.
After restarting the nginx server, the problem disappeared temporarily and then started again. I checked in both Nginx and laravel logs, there would be no error.
The text was updated successfully, but these errors were encountered: