**摘要:**由于测试需要,需用nginx搭建cdn服务器,并要求可以使用ftp上传。送个之前nginx搭建cdn的–>飞机票,下面是主要vsftp的配置,nginx配置cdn参照飞机票那篇即可。

搭建nginx cdn服务器

  • 具体参照使用nginx作cdn源站
  • nginx默认不开启文件目录显示,需要自行手动修改开启,在nginx.conf文件(/usr/local/nginx/conf/)里的http{}里面加入如下代码:
  • 如显示不正常需删除多余index页面
1
2
3
4
5
6
7
8
autoindex on;
#PS:另外两个参数最好也加上去
autoindex_exact_size off;
#默认为on,显示出文件的确切大小,单位是bytes。
#改为off后,显示出文件的大概大小,单位是kB或者MB或者GB
autoindex_localtime on;
#默认为off,显示的文件时间为GMT时间。
#改为on后,显示的文件时间为文件的服务器时间

搭建ftp服务器(来源:参照Johnny整理的步骤整合)

  • 安装软件
1
yum install vsftpd -y
  • 修改配置文件
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
#[root@stag-gw-cnd conf.d]# cat /etc/vsftpd/vsftpd.conf | egrep -v "^$|^#"
anonymous_enable=NO
local_enable=YES
write_enable=YES
local_umask=022
dirmessage_enable=YES
xferlog_enable=YES
connect_from_port_20=YES
xferlog_std_format=YES
listen=YES
chroot_local_user=YES
local_root=/usr/share/nginx/cdn/Test
pasv_promiscuous=YES
pasv_enable=YES
pasv_max_port=10100
pasv_min_port=10090
pam_service_name=vsftpd
userlist_enable=YES
tcp_wrappers=YES
  • 防火墙配置
1
2
3
4
vim /etc/sysconfig/iptables
iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 21 -j ACCEPT
iptables -I INPUT -p tcp --destination-port 10090:10100 -j ACCEPT
/etc/init.d/iptables save
  • 服务配置
1
2
service vsftpd restart
iptables -nvL
  • 用户配置
1
2
3
4
5
adduser ftptest
passwd ftptest
usermod -s /sbin/nologin ftptest
usermod -d /usr/share/nginx/cdn/Test ftptest
chown dcxjftp:ftp -R /usr/share/nginx/cdn/Test
  • 安全配置
1
2
3
vim /etc/pam.d/vsftpd
#注释下面这行
#auth       required  pam_shells.so

以上