[英]how to connect nginx proxy_pass to aiohttp webserver in python (Error)
Im trying to connect my nginx proxy_pass to my aiohttp web server But im keep getting errors我试图将我的 nginx proxy_pass 连接到我的 aiohttp Web 服务器但我不断收到错误
Here is my Nginx config:这是我的 Nginx 配置:
server {
server_name www.example.com;
location /nextpay {
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_redirect off;
proxy_buffering off;
proxy_pass https://127.0.0.1:5001;
}
}
And here is my code :这是我的代码:
from aiohttp import web
from aiohttp.web_request import Request
WEB_SERVER_HOST = "127.0.0.1"
WEB_SERVER_PORT = 5001
Router = web.RouteTableDef()
@Router.get('/nextpay')
async def verify(request: Request):
print(type(request))
return web.Response(text="Hello, world")
def main():
app = web.Application()
app.add_routes(Router)
web.run_app(app, host=WEB_SERVER_HOST, port=WEB_SERVER_PORT)
if __name__ == "__main__":
main()
And this is the error im keep getting every time i request on /nextpay :这是我每次在 /nextpay 上请求时都会遇到的错误:
aiohttp.http_exceptions.BadStatusLine: 400, message="Bad status line 'invalid HTTP method'"
The Problem was that i used https
instead of http
:问题是我使用https
而不是http
:
server {
server_name www.example.com;
location /nextpay {
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_redirect off;
proxy_buffering off;
proxy_pass http://127.0.0.1:5001;
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.