加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 运营中心 > Nginx > 正文

如何仅使用nginx将特定文件添加到特定文件中

发布时间:2020-12-13 21:23:41 所属栏目:Nginx 来源:网络整理
导读:我有图片,我想添加他们的标题为最大,我有个人资料的图片,可以更改和发布图片,我想添加标题只为后期图片,但不是个人资料图片,我不知道如何管理这个.谢谢,这是我的配置, this is the path of posts,/post/name-of-the-picture.jpgthis is the path of users,/u

我有图片,我想添加他们的标题为最大,我有个人资料的图片,可以更改和发布图片,我想添加标题只为后期图片,但不是个人资料图片,我不知道如何管理这个.谢谢,这是我的配置,

this is the path of posts,/post/name-of-the-picture.jpg

this is the path of users,/user/name-of-the-picture.jpg

我只想添加标题来发布路径

location ~* .(css|js|png|gif)${
   expires max;
   add_header Pragma public;
   add_header Cache-Control "public";
}
最佳答案
目前我们有两个选择来解决这个问题:

选项1:

Duplicated locations: NGINX looks for the best match. (a little better performance)

location /post/ {
    post config stuff;
    .
    .
    .
}    
location ~* ^/post/.*.(css|js|png|gif)${
    post/files.(css|js|png|gif) config stuff;
    expires max;
    add_header Pragma public;
    add_header Cache-Control "public";
}
location /user/ {
    user folder config stuff;
    .
    .
    .
}    
location ~* ^/user/.*.(css|js|png|gif)${
    user/files.(css|js|png|gif) config stuff;
    .
    .
    .
}

选项二:

Nested locations: Filtered by extension in the inner location blocks

location /post/{
    ...

    location ~* .(css|js|png|gif)${
        expires max;
        add_header Pragma public;
        add_header Cache-Control "public";
    }
}
location /user/{
    ...

    location ~* .(css|js|png|gif)${
        ...

    }
}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读