动静分离

静态资源部署在nginx服务器

nginx来当做静态资源服务器

来自80端口的请求会去nginx服务器根路径下的data文件夹查找

http://xxx.xxx.xxx.xx/static/a/logo.png 会请求根路径下 /data/static/a/logo.png

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
http {
include mime.types;
default_type application/octet-stream;


server {
listen 80;
server_name xxx.xxx.xxx.xxx;

#charset koi8-r;

#access_log logs/host.access.log main;

location /static/ {
root /data/;
}

}
}

转发到静态资源服务器

转发时使用负载均衡配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
http {
include mime.types;
default_type application/octet-stream;
upstream stack_pools {
server 172.25.254.134:80 weight=5;
}
upstream dynamic_pools {
server 172.25.254.135:80 weight=5;
}
server {
listen 80;
server_name xxx.xxx.xxx.xx;
location / {
root html;
index index.html index.htm;
proxy_pass http://dynamic_pools;
}
location /image/ {
proxy_pass http://stack_pools;
}
location /dynamic/ {
roxy_pass http://dynamic_pools;
}
}
}
打赏
  • 版权声明: 本博客所有文章除特别声明外,著作权归作者所有。转载请注明出处!
  • Copyrights © 2015-2025 SunZhiqi

此时无声胜有声!

支付宝
微信