使用Nginx配置资源目录展示下载】的更多相关文章

nginx配置文件 server { listen 8080; server_name localhost; charset utf-8; location /download { #下载的资源目录 绝对路径 最后 "/" 结尾 alias /usr/share/nginx/html/cc/temp/; autoindex on; autoindex_format html; #以html风格将目录展示在浏览器中 autoindex_exact_size off; #切换为 off 后…
访问我的博客 之前在网上找 CentOs 的镜像的时候,发现了阿里云的这个镜像源,速度蛮快的.今天也来搭建一个类似的站,使用 nginx 作为资源下载服务器. 图片详情: 安装 Nginx 参考这篇教程的 Nginx 环境搭建部分 设置资源存储路径 1. 资源准备 在 home 的用户目录下,建立文件夹,如 softs ,在 softs 目录中放入文件内容. 修改配置文件 2. 修改 Nginx 配置文件 vim conf/nginx.conf 添加 server server { listen…
比如说想要把 /home/source 目录作为资源目录,那么需要如下配置: location /source/ { #识别url路径后,nginx会到/home/文件路径下,去匹配/source root /home/; #开启目录浏览下载功能 autoindex on; } 可能出现的误区:如下 location /source/ { #识别url路径后,跳转到/home/source目录路径下,去匹配/source root /home/source; #开启目录浏览下载功能 autoin…
   当配置Nginx来映射不同的服务器 可以通过二级路径来反向代理 来解决一个外网端口实现多个服务访问. 配置如下: server { listen ; server_name demo.domain.com; #通过访问service二级目录来访问后台 location /service/ { #DemoBackend1后面的斜杠是一个关键,没有斜杠的话就会传递service到后端节点导致404 proxy_pass http://backend1/; proxy_redirect off;…
场景描述: 通过二级目录(虚拟目录,应用程序)的方式访问同一ip+端口的不同应用,例如location是用户使用页面,location/admin/是管理页面,location部署在192.168.1.100的80端口,location/admin部署在172.20.1.32的8080端口上. 解决方案: 使用nginx反向代理,配置如下: server { listen 80; server_name demo.domain.com; #通过访问service二级目录来访问后台 locatio…
应用环境:通常放置一些文件来提供下载. 配置环境:centos7 //已经关闭Selinux和Firewall 需求假设:在网页输入主机IP并进入,会显示主机目录/home/share/的文件以提供下载功能. 操作步骤: 1. 安装Apache(httpd) ~]#yum install -y httpd 2. 编辑httpd配置文件 ~]#vim /etc/httpd/conf/httpd.conf 在末尾下添加如下内容: 保存,退出: 3.  删除文件welcome.conf 在目录/etc…
不实用Nginx的时候我们会使用虚拟路径来配置: 在tomcat下的conf/server.xml中增加一个代码 在<Host></Host>中间 如下: <!--增加的--path="/虚拟名" docBase="虚拟路径" -> <Context path="/upload" docBase="D:\pic\"  reloadable="true"><…
有时候在服务器上配置某些文件比如TXT文件,在浏览器打开的时候,会弹出下载.如何只让他在浏览器中显示,而不是下载呢.在nginx配置文件中添加一行代码 add_header Content-Type text/plain; //文件内容以文本格式显示 //例如 location = /md/test.txt { //匹配到这里,显示文件内容,而不是下载 root /home/wwwroot/default; add_header Content-Type text/plain; }…
缓存nginx服务器的静态文件.如css,js,htm,html,jpg,gif,png,flv,swf,这些文件都不是经常更新.便于缓存以减轻服务器的压力. 打开配置文件/usr/local/nginx/conf/nginx.conf 把下面内容加在http里面 proxy_connect_timeout ; proxy_read_timeout ; proxy_send_timeout ; proxy_buffer_size 16k; proxy_buffers 64k; proxy_bus…
1. 这是根据实际情况来写的. location /h5/activity/wechat/ {            index  index.html index.htm index.php;            try_files $uri $uri/ /h5/activity/wechat/index.html;        } 这是项目直接放在根目录下的情况. location / {            index  index.html index.htm index.php;…