mrludan1994 发表于 2017-8-28 18:31:30

nginx反向代理,如何对指定后缀的文件进行缓存?

nginx反向代理,如何对指定后缀的文件进行缓存?

WordPress迷 发表于 2017-8-28 18:53:55

搭车同问,反代百度 H5 有成功的老司机吗?有的PM,200金币幸苦费
lol.gif

suwubee 发表于 2017-8-28 19:27:48

location里加

mrludan1994 发表于 2017-8-28 20:20:04


suwubee 发表于 2017-8-28 19:27

location里加
求教加什么代码?

xfspace 发表于 2017-8-28 19:27:00

"
return 301 http://www.gov.cn

mrludan1994 发表于 2017-8-28 22:10:14


xfspace 发表于 2017-8-28 22:10

return 301 http://www.gov.cn
卖萌?

aboutyj 发表于 2017-8-28 20:20:00

本帖最后由 aboutyj 于 2017-8-30 10:09 编辑
[*]nginx.conf
[*]
[*]http {
[*]    ......
[*]
[*]    proxy_temp_path   /PATH;
[*]    proxy_cache_path/PATH levels=1:2 keys_zone=cache_file:1024m inactive=7d max_size=10g;
[*]    ......
[*]}复制代码
[*]yourconf.conf
[*]
[*]server {
[*]    ......
[*]
[*]    location ~ .*\.(js|css|gif|jpg|jpeg|png|bmp|ico)$ {
[*]         proxy_pass http(s)://yourbackend;
[*]         proxy_set_header   Host $http_host;
[*]         proxy_redirect off;
[*]         proxy_cache cache_file;
[*]         proxy_cache_valid 200 302 1h;
[*]         proxy_cache_valid 301 1d;
[*]         proxy_cache_valid any 1m;
[*]         expires 7d;
[*]    }
[*]    ....
[*]}复制代码

mzxx 发表于 2017-8-30 08:58:20


aboutyj 发表于 2017-8-30 10:03

收藏一下。
页: [1]
查看完整版本: nginx反向代理,如何对指定后缀的文件进行缓存?