iis服务器助手广告广告
返回顶部
首页 > 资讯 > 服务器 >nginx代理下载服务器文件的方法
  • 605
分享到

nginx代理下载服务器文件的方法

2023-06-29 02:06:01 605人浏览 安东尼
摘要

今天小编给大家分享一下Nginx代理下载服务器文件的方法的相关知识点,内容详细,逻辑清晰,相信大部分人都还太了解这方面的知识,所以分享这篇文章给大家参考一下,希望大家阅读完这篇文章后有所收获,下面我们一起来了解一下吧。主旨Nginx是一款轻

今天小编给大家分享一下Nginx代理下载服务器文件的方法的相关知识点,内容详细,逻辑清晰,相信大部分人都还太了解这方面的知识,所以分享这篇文章给大家参考一下,希望大家阅读完这篇文章后有所收获,下面我们一起来了解一下吧。

主旨

Nginx是一款轻量级的WEB服务器/反向代理服务器及电子邮件(IMAP/POP3)代理服务器,在BSD-like 协议下发行。其特点是占有内存少,并发能力强,事实上nginx的并发能力在同类型的网页服务器中表现较好。

环境

linux服务器
nginx软件

nginx安装

1、安装编译工具及库文件

‍[yunweijia@localhost jier]$ sudo yum -y install make zlib zlib-devel GCc-c++ libtool  openssl openssl-devel

2、**安装 PCRE

[yunweijia@localhost jier]$ cd /usr/local/src/[yunweijia@localhost src]$ sudo wget Http://downloads.sourceforge.net/project/pcre/pcre/8.35/pcre-8.35.tar.gz  下载[yunweijia@localhost src]$ sudo tar xf pcre-8.35.tar.gz  # 解压[yunweijia@localhost src]$ cd pcre-8.35/[yunweijia@localhost pcre-8.35]$ sudo ./configure  # 编译[yunweijia@localhost pcre-8.35]$ sudo make && make instal  # 安装[yunweijia@localhost pcre-8.35]$ pcre-config --version  # 版本查看8.32[yunweijia@localhost pcre-8.35]$

3、安装nginx

[yunweijia@localhost jier]$ pwd/home/yunweijia/jier[yunweijia@localhost jier]$ lsnginx-1.14.2.tar.gz[yunweijia@localhost jier]$ tar xf nginx-1.14.2.tar.gz [yunweijia@localhost jier]$ cd nginx-1.14.2/[yunweijia@localhost nginx-1.14.2]$ sudo ./configure --prefix=/home/yunweijia/nginx --with-http_stub_status_module --with-http_ssl_module --with-pcre=/usr/local/src/pcre-8.35[yunweijia@localhost nginx-1.14.2]$ sudo make && make install

4、配置调整

[yunweijia@localhost nginx-1.14.2]$ cd /home/yunweijia/nginx/[yunweijia@localhost nginx]$ lsconf  html  logs  sbin[yunweijia@localhost nginx]$ vim conf/nginx.conf# 以下内容是配置文件的第二行进行配置user root;# 以下配置是唉server中进行新增        location ~* (.*.txt) {  # 代理后缀为txt的            add_header  Content-Type    "application/octet-stream";            if ( $args ~ ^filename=(.*) ) {                add_header  Content-Disposition "attachment; filename=$1";            }            yunweijia /home/yunweijia/txt/;  # 在这个目录下        }

5、启动nginx

[yunweijia@localhost nginx]$ sudo ./sbin/nginx -t  # 检查配置nginx: the configuration file /home/yunweijia/nginx/conf/nginx.conf syntax is oknginx: configuration file /home/yunweijia/nginx/conf/nginx.conf test is successful[yunweijia@localhost nginx]$ sudo ./sbin/nginx  # 启动

6、验证

在"/home/yunweijia/txt/"中新建文件,测试下载。

下载url为:http://ip地址:端口号/文件名

[yunweijia@localhost nginx]$ mkdir /home/yunweijia/txt/[yunweijia@localhost nginx]$ cd /home/yunweijia/txt/[yunweijia@localhost txt]$ ls[yunweijia@localhost txt]$ echo ceshi > 1.txt[yunweijia@localhost txt]$ cat 1.txt ceshi[yunweijia@localhost txt]$

浏览器输入地址为:http://192.168.112.130/1.txt

文件下载成功。

以上就是“nginx代理下载服务器文件的方法”这篇文章的所有内容,感谢各位的阅读!相信大家阅读完这篇文章都有很大的收获,小编每天都会为大家更新不同的知识,如果还想学习更多的知识,请关注编程网服务器频道。

--结束END--

本文标题: nginx代理下载服务器文件的方法

本文链接: https://www.lsjlt.com/news/321945.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作