帮我配置 nginx-varnish-uwsgi-django

发布于 2024-10-17 14:10:02 字数 843 浏览 6 评论 0原文

我正在使用 nginx-uwsgi 部署我的 django 应用程序 我想将清漆添加到这个堆栈中。 据我所知 Varnish 只能缓存 ip 和端口。 但我的堆栈是这样配置的:

location / { 
            uwsgi_pass unix://home/mechanism/SERVER/run/MechanisM.sock; 
            include uwsgi_params;

        } 

所以我的 nginx 与 uwsgi 的套接字一起工作。不是ip和端口。 但 Varnish 需要 ip 和端口。像这样:

backend default {
      .host = "127.0.0.1";
      .port = "8080";
}

我应该更改 uwsgi 以使用 ip 和端口运行吗?或者有什么方法可以配置 Varnish 与 uwsgi 的 sock 一起使用?或者如何知道这个套接字的IP和端口?

顺便说一句,我用这个命令启动 uwsgi:

exec /usr/sbin/uwsgi --socket /home/mechanism/SERVER/run/MechanisM.sock --chmod-socket --module wsgi_app --pythonpath /home/mechanism/SERVER/django-projects/MechanisM/uwsgi -p 12 -t 15

我应该使用 -s 127.0.0.1:3031 而不是 --socket /home/mechanism/SERVER/run/MechanisM.sock 吗?

I'm deploying my django app with nginx-uwsgi
I wanna add Varnish to this stack.
As I know Varnish can cache only ip and port.
But my stack configured this way:

location / { 
            uwsgi_pass unix://home/mechanism/SERVER/run/MechanisM.sock; 
            include uwsgi_params;

        } 

so my nginx works with uwsgi's socket. not ip and port.
but Varnish needs ip and port. like this:

backend default {
      .host = "127.0.0.1";
      .port = "8080";
}

should I change uwsgi to run with ip and port? or there's some way to configure Varnish to work with uwsgi's sock? or how to know ip and port of this socket?

btw, I'm starting uwsgi with this command:

exec /usr/sbin/uwsgi --socket /home/mechanism/SERVER/run/MechanisM.sock --chmod-socket --module wsgi_app --pythonpath /home/mechanism/SERVER/django-projects/MechanisM/uwsgi -p 12 -t 15

should I use -s 127.0.0.1:3031 instead of --socket /home/mechanism/SERVER/run/MechanisM.sock ??

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

南街女流氓 2024-10-24 14:10:02

Varnish 将缓存来自 nginx 的日期,而不是来自 uWSGI 的日期。

将 nginx 地址放入 varnish 中,而不是 uWSGI 中

Varnish will cache date coming from nginx, not from uWSGI.

Put the nginx address in varnish not the uWSGI one

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文