nginx 静态资源访问配置

 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;
        }

    }
原文地址:https://www.cnblogs.com/big-cut-cat/p/11624015.html