nginx静态文件访问
新建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
查看