使用http访问ftp文件,基于centos7

1。安装nginx

  默认源没有nginx,需添加nginx源

sudo rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
sudo yum install -y nginx
sudo systemctl start nginx.service
sudo systemctl enable nginx.service

2。vi /etc/nginx/conf.d/default.conf

修改

charset utf-8;

修改location/处为如下

root后面的为指定的文件夹

    location / {
#       root   /usr/share/nginx/html;
#       index  index.html index.htm;
        root /home/vsftpd/;
        autoindex on;
    }

3。关闭selinux

vi /etc/sysconfig/selinux修改如下

SELINUX=disabled

4。curl 127.0.0.1测试

5。开防火墙端口

firewall-cmd --permanent --add-port=80/tcp
firewall-cmd --reload

firewall-cmd --list-all 
然后外网访问测试

 

6。限速设置

vi /etc/nginx/nginx.conf

include /etc/nginx/conf.d/*.conf;这一行前面添加

limit_conn_zone $binary_remote_addr zone=one:10m;

vi /etc/nginx/conf.d/default.conf,每ip限两个连接,每个连接限速1m,location/添加

        limit_conn one 2;
        limit_rate 1m;

service nginx restart

 

7。友好视图设置

vi /etc/nginx/conf.d/default.conf,location/添加

autoindex_exact_size off;
autoindex_localtime on;

8。设置访问验证

提供一个在线工具:http://tool.oschina.net/htpasswd 在这里输入用户名密码后选择Crypt加密算法。

vi  /etc/nginx/passwd,添加上面生成的文本

vi /etc/nginx/conf.d/default.conf,location/添加

        auth_basic "Authorized users only";
        auth_basic_user_file /etc/nginx/passwd;

9。页面美化

https://phus.lu/autoindex.html下载autoindex.html文件放到上述根目录

vi /etc/nginx/conf.d/default.conf,location/添加

    add_after_body /autoindex.html;

 

10。添加readme.md文件

readme.md文件会自动读取显示在页面下方

换行的语法为添加<br>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值