1、配置静态前端工程
server { listen 80; server_name localhost; location / { root /home/files/uploadStaticResource/folder1; #root html; index index.html; } }
folder1文件夹就是存放的前端工程,里面放着一个index.html文件
2、配置资源
server { listen 80; server_name localhost; location / { root /home/files/uploadStaticResource/folder1; #root html; index index.html; } location /resource { root /home/files/uploadStaticResource; } }
在/home/files/uploadStaticResource文件夹下放着一个resource文件夹
访问测试:
使用别名的方式配置静态资源
location /static { alias /home/files/uploadStaticResource/resource; }
访问方式: http://www.xxx.xx/static/imgs/1.jpg