A-A+
Tengine(Nginx)动静分离简要配置
要点:根据URL规则,分离静态资源。例子中是根据“/static/”这个路径分离
1、把原应用服务器的static文件夹移到Tengine的html文件夹下
2、配置nginx.conf,把URL“/static/”的全部转到Tengine的html下,在server {}中增加:
location ~* /static/ { root html; } |
3、配置nginx.conf,把其他的请求全部转到应用服务器(Tomcat),
A.配置应用服务器集合,在http {}中增加:
upstream testwww{ server 192.168.0.103:9080; } |
B.把其他的请求全部转到应用服务器集合“testwww”,修改server {}中的location / {}:
location / { proxy_pass http://testwww; root html; index index.html index.htm; } |
4.完成。
评论已关闭!