Skip to content

Exception if Running with Nginx #1305

@lfaltran

Description

@lfaltran

What Happened?

Running on premise behind a NGINX proxy I got error bellow:

Request

curl --location 'https://llm.*****.com.br/v1/chat/completions' \
--header 'Content-Type: application/json' \
--header 'x-portkey-provider: google' \
--header 'Authorization: <hidden>' \
--data '{
    "messages": [
        {
            "role": "user",
            "content": "Hello, how are you?"
        }
    ],
    "model": "gemini-2.5-pro"
}'

Response

<html>

<head>
    <title>502 Bad Gateway</title>
</head>

<body>
    <center>
        <h1>502 Bad Gateway</h1>
    </center>
    <hr>
    <center>nginx/1.29.0</center>
</body>

</html>

Server Error:
[error] 596985#596985: *1 upstream sent "Content-Length" and "Transfer-Encoding" headers at the same time while reading response header from upstream, client: 177.92.13.158, server: llm.*****.com.br, request: "POST /v1/chat/completions HTTP/1.1", upstream: "http://172.17.10.2:8787/v1/chat/completions", host: "llm.*****.com.br"

What Should Have Happened?

IA Response

Relevant Code Snippet

Request Headers sent to server:

Request Headers
Content-Type: application/json
x-portkey-provider: google
Authorization: <hidden>
User-Agent: PostmanRuntime/7.45.0
Accept: */*
Cache-Control: no-cache
Postman-Token: 90a49034-e907-49f3-9ba6-0e02d0cd13b1
Host: llm.*****.com.br
Accept-Encoding: gzip, deflate, br
Connection: keep-alive
Content-Length: 151
Response Headers
Server: nginx/1.29.0
Date: Wed, 27 Aug 2025 17:43:41 GMT
Content-Type: text/html
Content-Length: 157
Connection: keep-alive

Your Twitter/LinkedIn

https://www.linkedin.com/in/lfaltran

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtriage

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions