[英]How to use Django Nginx Application with both HTTP and HTTPS requests?
[英]Docker-Django-Nginx problem with http/https
我正在嘗試測試 Docker 中的設置。運行 python 應用程序的 web 服務器,我想添加 Nginx 服務來為其提供服務。 我得到的結果是“400 錯誤請求”錯誤
在 Nginx 容器中,我使用 curl 和 wget 進行了這些測試,結果如下: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>
Python 容器響應如下:`
[05/Dec/2022 13:34:58] You're accessing the development server over HTTPS, but it only supports HTTP.
這是我的 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;
}
}
`
我不明白為什么請求會混淆,如果我的配置是http,那就是開發階段。 謝謝...
Nginx -> Python 連接是 HTTPS 因為你有
proxy_pass https://web_python;
在您的 nginx 配置中。
改成
proxy_pass http://web_python;
讓 nginx 通過 HTTP 與 python 通話。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.