Django实例前面的HAProxy负载均衡器

nsi*_*ide 3 django

我想让haproxy缓存/重定向我的django实例的/static/.+ url路径来加速静态文件服务.最好的方法是什么?

小智 5

据我所知,HAProxy不进行缓存.为此你想要像鱿鱼这样的东西.

对于/ static/seperately,您可以设置HAProxy配置以将与模式匹配的任何URL重定向到另一个后端集群:

frontend my_website *:80
    mode http
    acl static url_beg /static/
    use_backend my_static_proxy if static
    default_backend my_django_server
Run Code Online (Sandbox Code Playgroud)