实例:
A服务器:nginx
B服务器:文件系统
需求:通过A服务器的域名访问B服务器里面的图片
处理方式:B服务器同样安装nginx,通过A服务器nginx跳转到B服务器nginx访问图片
A服务器nginx配置:
location ~ .*\.(gif|jpg|jpeg|png)$ {
rewrite /(.*)$ /$1 break;
autoindex on;
proxy_pass http://服务器B的IP;
}
rewrite:上面例子(.*)是将所有参数传给$1,转发时/$1会拼接在http://B服务器后面。
B服务器(80端口):
location /image/ {
autoindex on;
root /home/fdfs_storage/data/image/;
}
A服务器域名/1568635213963.png 即可访问