需求:vue项目打包的时候 会将项目中的一些图片打包到/dist/static/images下,但是有时候会有一些很大的图片,需要单独存放至别的文件夹比如/home/di-img下,不能被打倒包内。部署的时候这些大的图片的文件夹还可以被访问到。如何配置?

直接贴配置:

#user  nobody;
worker_processes 1; #error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info; #pid logs/nginx.pid; events {
worker_connections 1024;
} http {
include mime.types;
default_type application/octet-stream; #log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"'; #access_log logs/access.log main; sendfile on;
#tcp_nopush on; #keepalive_timeout 0;
keepalive_timeout 65; #gzip on; server {
listen 8081;
server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; location / {
root html;
index index.html index.htm;
try_files $uri $uri/ /index.html;
autoindex on;
} location /api/ {
proxy_pass http://192.168.x.xx:8080/;
}
  #此/home/di-img文件夹是用来单独存放大图的
location /di-img {
alias /home/di-img/;
autoindex on;
} #error_page 404 /404.html; # redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
} # proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#} # deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
} # another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias; # location / {
# root html;
# index index.html index.htm;
# }
#} # HTTPS server
#
#server {
# listen 443 ssl;
# server_name localhost; # ssl_certificate cert.pem;
# ssl_certificate_key cert.key; # ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m; # ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on; # location / {
# root html;
# index index.html index.htm;
# }
#}
}

启动nginx

浏览器访问包内的图片:http://192.168.x.xx:8081/static/images/xxxx.png  可能images下还有别的文件夹 别忘记拼上去

访问外部的大图片:http://192.168.x.xx:8081/di-img/xxx.png

最新文章

  1. bzoj 1711 [Usaco2007 Open]Dining吃饭&&poj 3281 Dining
  2. T4 模板自动生成带注释的实体类文件 - 只需要一个 SqlSugar.dll
  3. jQueryt过滤选择器
  4. IOS --- OC与Swift混编
  5. Linux IPC tcp/ip socket 编程
  6. iOS开发——项目实战总结&经典错误一
  7. ace布置小作业: 制作一个简单的电话号码归属地查询软件:JSON解析和Volly发送get请求
  8. Linux prerouting和postrouting的区别
  9. BZOJ 1816 扑克牌
  10. html转义函数
  11. Android EditText如何去除边框添加下划线
  12. 关于 jquery.showLoading 中 出现的 图标不在页面中间的问题
  13. 强联通 HDU 1269
  14. Qt widget--杭州小笼包
  15. ROS tf 两个常用的函数
  16. Spring data Jpa 分页从1开始,查询方法兼容 Mybatis,分页参数兼容Jqgrid
  17. Cocos2d-JS studio基础控件的使用
  18. Android Studio 之 Launch AVD 时" Intel HAXM is required to run this AVD, VT-x is disabled in BIOS; "
  19. 【javascript】浮点数运算问题分析及解决方法
  20. Android Usb Camera HAL框架

热门文章

  1. Python 简明教程 ---10,Python 列表
  2. 05【掌握】 SpringBoot 清空Redis所有缓存
  3. 恕我直言你可能真的不会java第9篇-Stream元素的匹配与查找
  4. emacs-显示行号以及跳转到指定行
  5. Java并发编程(06):Lock机制下API用法详解
  6. (五)ELK Logstash output
  7. Promise内部实现原理
  8. 洛谷 P4042 [AHOI2014/JSOI2014]骑士游戏
  9. Python——查看目录下所有的目录和文件
  10. java 基本语法(十九)Optional类的使用