nginx 静态资源访问配置

来源:互联网 发布:网络言情小说作家 编辑:程序博客网 时间:2024/05/21 06:46
    server {
        listen 443;
        server_name localhost;
        ssl on;

# 此处可配置域名访问,默认的首页

#       root html;   #目录
#       index weixin/index.html;

#       rewrite ^/ https://www.baidu.com  


#       location / {
#               root html;
#               index index.html index.htm;
#       }

# 配置所有的静态资源访问路径
        location ~ .*\.(html|htm|gif|jpg|jpeg|bmp|png|ico|txt|js|css)$
        {
                root html/weixin;   #目录
                index index.html;
                #expires定义用户浏览器缓存的时间为1天,如果静态页面不常更新,可以设置更长,这样可以节省带宽和缓解服务器的压力
                expires      1d;

        }

    }


原创粉丝点击