0

I'm trying to test a setup in Docker. A web server running a python application, and I want to add an Nginx service to serve it. The result I am getting is "400 bad request" error

In the Nginx container I do these tests with curl and wget, and these are the results: WGET

root@b301fc0bb378:/# wget http://web_python:8000
--2022-12-05 19:01:06--  http://web_python:8000/
Resolving web_python (web_python)... 172.23.0.3
Connecting to web_python (web_python)|172.23.0.3|:8000... connected.
HTTP request sent, awaiting response... 400 Bad Request
2022-12-05 19:01:06 ERROR 400: Bad Request.`

CURL

root@b301fc0bb378:/# curl http://web_python:8000

<!doctype html>
<html lang="en">
<head>
  <title>Bad Request (400)</title>
</head>
<body>
  <h1>Bad Request (400)</h1><p></p>
</body>
</html>

The Python container responds this: `

[05/Dec/2022 13:34:58] You're accessing the development server over HTTPS, but it only supports HTTP.

This is my nginx.conf: `

upstream web_python {
    server web_python:8000;
}

server {

    listen 80;

    location / {
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header Host $host;
        proxy_redirect off;
        proxy_pass http://web_python;
    }

}

`

I do not understand why the requests are confused, if my configurations are in http, it is the development phase. Thank you...

1 Answers1

1

The Nginx -> Python connection is HTTPS because you have

proxy_pass https://web_python;

in your nginx config.

Change it to

proxy_pass http://web_python;

to have nginx talk to python over HTTP.

Hans Kilian
  • 18,948
  • 1
  • 26
  • 35
  • Sorry, my mistake in phrasing the question. That https is because I was trying to take it to that protocol. What I currently have is: http://web_python:8000 – René Sánchez Dec 06 '22 at 02:07