首页 > 其他 > 详细

nginx静态文件访问

时间:2018-01-08 00:30:51      阅读:244      评论:0      收藏:0      [点我收藏+]

新建staticServer.conf(先配置二级解析域名)

#static
server
{
    listen 80;
    server_name static.maoriaty.top;

    expires 300d;
    gzip on;

    location / {
        root  /app/deploy/static;
        index index.html index.htm;
    }

    rewrite ^/upload/(.*)$ /upload/$1 last;
    rewrite ^/(.*)/(\d+)/(.*)$ /$1/$3 last; #重写url去除缓存时间戳
}

#image
server
{
    listen 80;
    server_name img.maoriaty.top;

    expires 300d;
    gzip on;

    location / {
        root  /app/deploy/static;
        index index.html index.htm;
    }
}

#file
server
{
    listen 80;
    server_name file.maoriaty.top;

    expires 300d;
    gzip on;

    location / {
        root  /app/deploy/static;
        index index.html index.htm;
    }
}
                                              

修改nginx.conf

include staticServer.conf; #在http里最后添加

 重启

nginx -s reload

查看

技术分享图片

 

nginx静态文件访问

原文:https://www.cnblogs.com/maoriaty/p/8232827.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!