运行使用Gunicorn和Nginx的容器化烧瓶应用程序
最近,我一直在为 nginx 处理反向代理在包含我项目的容器中的所有流量,最重要的是,最重要的是 nginx ,最重要的是 nginx ,最重要的是,最重要的是 nginx ,最重要的是,最重要的是 strong>烧瓶并使用 gunicorn wsgi 我尝试使用 dockerfile,docker-compose 等多次尝试... 我得到的最接近的是使用这篇文章。
这些是我遵循的步骤安装docker。
即使在那时,它也不是例子说的,也无法看到烧瓶显示的消息,而只是看到了NGNX安装成功的消息。 即使它起作用,我也被Python服务器上的人们建议使用Gunicorn (这很有意义),我无法将其切换出来,最重要的是要在外面有 nginx容器,其中Nginx只会将流量处理到其他容器中而无需一个容器,我也无法脱离。 我来自“ heroku”背景,所以我要做这件事仍然有些复杂,我看过无数的视频和解释,但是我找不到对我的特定案例有一个很好的教程的人。 > gunicorn,nginx,烧瓶,docker “。 这是很多要问的,所以我并不是真的期望如何做到这一点(即使我真的很感激),也不是逐步的指南,但是指向我朝正确的方向指向正确的方向,就像我正在做的事情可以更有效或更好的方式做吗?如果不是这样,您建议我调查吗?文章,文档链接,任何东西,打我!
我会显示我最终发现的文件,但它们是让Nginx在一个容器中,这不是我希望我的最终结果,而它们无论如何都没有工作,所以我希望从头
开始我建议弄清楚的步骤(我仍在研究它们,因为我正在恢复并慢慢进行此操作,与上次不同):
- 弄清楚使用Gunicorn使用Gunicorn运行您的应用程序的
- 命令确保您可以构建容器
- 公开容器的端口,并确保您可以正确地
- 使用nginx转发这些请求
I've been working on my VPS lately in a goal which is to have nginx handle all traffic in a reverse proxy to containers which contain my projects, which most importantly are flask and ran using gunicorn wsgi
I've tried multiple attempts using Dockerfile, docker-compose, etc...
The closest thing I got was using this post.
And those are the steps I followed to install docker.
Where even then it did not as the example said and wasn't able to see the message displayed by flask but only saw the ngnx installation successful message.
Even if it worked, I was suggested by people on the python server to use gunicorn (which makes sense) and I wasn't able to switch it out, and most importantly to have nginx OUTSIDE the container, where nginx would just handle the traffic into the other containers without being in one, which I also couldn't pull off.
I come from a "heroku" background so It's still a little complicated for me to pull this off, I've watched countless videos and explanations online but I couldn't find anyone that had a good tutorial on my specific case of "gunicorn, nginx, flask, docker".
This is a lot to ask so I'm not really expecting a detailed explanation on how to do this (even though I would REALLY appreciate that), nor a step by step guide of course, but pointing me in the right direction would, like is there something I'm doing that could be done in a more efficient or just better manner? if not then is there anything you suggest I look into? articles, docs links, anything, hit me with it!
I would show the files I ended up with but they were made for nginx to be inside a container which isn't what I want my end result to be and they didn't work anyways so I'm hoping to start from scratch
Those are the steps I was suggested to figure out (I'm still working on them because I'm restarting and taking this slowly, unlike last time):
- Figure out the command to run your app using gunicorn
- Add that command to your dockerfile, and make sure you can build the container
- Expose the container's ports and make sure you can make your requests correctly
- Use NGINX to forward those requests
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不知道这是否会为您提供帮助,但是对于在容器内烧烤的烧瓶,我建议您遵循本教程: https://mark.douthwaite.io/getting-production-production-aready-a-readimal-minimal-flask-app/
带有源代码: https://github.com/markdouthwaite/mmarkdouthwaite/minimal-flask-api
亲自帮助我很多。
也许接下来您要构建图像:
Dockerfile所在的位置,然后用类似的东西运行容器。
,然后使用Nginx在Local主机上设置代理路径:8080/
I don't know if this will help you, but for flask with gunicorn inside a container, I suggest you to follow this tutorial : https://mark.douthwaite.io/getting-production-ready-a-minimal-flask-app/
with its source code : https://github.com/markdouthwaite/minimal-flask-api
Personally, it helped me a lot.
Maybe next you want to build the image :
where the dockerfile is located and then and run the container with something like :
And then use Nginx to set a proxy path on localhost:8080/