无法访问使用 uWSGI 和 Nginx 提供的 Flask 应用程序
我有一个 Flask 后端,无需使用 uwsgi 和 nginx 即可运行。 我正在尝试将其部署在具有前端的 EC2 实例上。
无论我做什么,我都无法到达后端。我出于测试目的打开了所有端口,但这没有帮助。
这是我的 uwsgi ini 文件:
[uwsgi]
module = main
callable = app
master = true
processes = 1
socket = 0.0.0.0:5000
vacuum = true
die-on-term = true
然后我使用此命令启动应用程序:
uwsgi --ini uwsgi.ini
返回的消息是
WSGI app 0 (mountpoint='') ready in 9 seconds.
spawned uWSGI worker 1 (and the only) PID: xxxx
然后这是我的 Nginx conf 文件:
server {
server_name my_name.com www.ny_name.com
location / {
root /home/ubuntu/front_end/dist/;
}
location /gan {
proxy_pass https:localhost:5000/gan;
}
## below https conf by certbot
}
如果我的理解是正确的,每当请求到达“my_name.com/gan...”时,它就会被重定向到端口 5000 上的本地主机,其中后端由 uwsgi 启动。
但我够不到。我试图在浏览器上简单地对“my_name.com/gan”执行 get 请求(它应该返回随机图像),但我收到 nginx 的 502 错误。
需要注意的是,前端工作正常,我可以在浏览器上访问它。
I have a Flask back end that is functional without using uwsgi and nginx.
I'm trying to deploy it on an EC2 instance with its front-end.
No matter what I do, I can't reach the back-end. I opened all the ports for testing purposes but that does not help.
Here's my uwsgi ini file:
[uwsgi]
module = main
callable = app
master = true
processes = 1
socket = 0.0.0.0:5000
vacuum = true
die-on-term = true
Then I use this command to start the app:
uwsgi --ini uwsgi.ini
The message returned is
WSGI app 0 (mountpoint='') ready in 9 seconds.
spawned uWSGI worker 1 (and the only) PID: xxxx
Then here is my Nginx conf file:
server {
server_name my_name.com www.ny_name.com
location / {
root /home/ubuntu/front_end/dist/;
}
location /gan {
proxy_pass https:localhost:5000/gan;
}
## below https conf by certbot
}
If my understanding is correct, whenever a request reaches "my_name.com/gan..." it will be redirected to the localhost on the port 5000 where the back-end is started by uwsgi.
But I can't reach it. I'm trying to simply do a get request on "my_name.com/gan" on my browser (it should return a random image) but I get a 502 by nginx.
Important to note, the front-end works fine and I can access it on browser.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我的猜测是 url 的格式不正确
尝试
proxy_pass http://0.0.0.0:5000;
My guess is that url is not in proper form
Try
proxy_pass http://0.0.0.0:5000;