nginx 静态内容

nginx 静态内容

我有一个以下部署的场景。

1x nginx 作为 gzip 和 ssl ofload 的前端服务器,将所有请求发送到同一服务器 haproxy 服务,监听 127.0.0.1:8000,为三个后端 IIS 网络服务器进行负载平衡。

现在我想将所有静态内容从我的后端 IIS 服务器(css​​、jpg、png、js……)移动到一台或两台后端 Nginx 服务器,以释放 IIS 的工作负载。

我想我必须在 nginx 上为静态内容添加另一条规则,以发送到 haproxy ACL,将请求转发到 2 或 3 个后端 nginx 服务器。

有谁遇到过同样的情况吗?

答案1

我自己找到了答案。nginx 前端不会做任何事情。我将使用 haproxy 进行 acl 路由...

# Static content
acl url_static path_beg /javascripts /stylesheets /images
acl url_static path_end .jpg .jpeg .gif .png .ico .pdf .js .css .flv .swf
acl host_static hdr_beg(host) -i static0. static1. static2. static3.

use_backend static if host_static or url_static

# Default to dynamic content
default_backend dynamic

相关内容