382 sudo yum install php-fpm
384 sudo vi /etc/php-fpm.d/www.conf
391 sudo vi /etc/nginx/nginx.conf
393 sudo /etc/init.d/php-fpm start
395 sudo chkconfig php-fpm on
396 sudo /etc/init.d/nginx restart

http://qiita.com/utano320/items/36b6eac2bbd5bb5657f6

★backend vsftpdサーバ×2

vi /etc/vsftpd/vsftpd.conf

pasv_enable=YES
pasv_min_port=60000
pasv_max_port=60001
pasv_address=lb.x.x.x

 

★frontend nginxサーバ

vi nginx.conf

stream {
#FTP
upstream ftp {
hash $remote_addr;
server vsftpd.nilesflow.net:21 weight=5 max_fails=3 fail_timeout=30s;
server aws-default.nilesflow.net:21 weight=5 max_fails=3 fail_timeout=30s;
# server pure-ftpd.nilesflow.net:10021 weight=5 max_fails=3 fail_timeout=30s;
}

server {
listen 20021;
proxy_connect_timeout 1s;
# proxy_timeout 3s;
proxy_pass ftp;
}

#FTP data
upstream ftpdata-v1 {
hash $remote_addr;
server vsftpd.nilesflow.net:60000 weight=5 max_fails=3 fail_timeout=30s;
server aws-default.nilesflow.net:60000 weight=5 max_fails=3 fail_timeout=30s;
}
upstream ftpdata-v2 {
server vsftpd.nilesflow.net:60001 weight=5 max_fails=3 fail_timeout=30s;
server aws-default.nilesflow.net:60001 weight=5 max_fails=3 fail_timeout=30s;
}

# vsftpd
server {
listen 60000;
proxy_connect_timeout 1s;
proxy_timeout 3s;
proxy_pass ftpdata-v1;
}
server {
listen 60001;
proxy_connect_timeout 1s;
proxy_timeout 3s;
proxy_pass ftpdata-v2;
}

 

★どこかのサーバから

ftp lb.nilesflow.net 20021

 

★補足

pasv_address= ドメイン名ではなくIPアドレス

vi /etc/vsftpd/vsftpd.conf

pasv_enable=YES
pasv_min_port=60000
pasv_max_port=60001
pasv_address=x.x.x.x

vi /etc/pure-ftpd/pure-ftpd.conf

Bind                            z.z.z.z,10021

PassivePortRange          60010 60011

ForcePassiveIP x.x.x.x

 

vi nginx.conf

stream {
#FTP
upstream ftp {
hash $remote_addr;
server z.z.z.z:21 weight=5 max_fails=3 fail_timeout=30s; #v
server z.z.z.z:10021 weight=5 max_fails=3 fail_timeout=30s; #p
}

server {
listen 20021;
proxy_connect_timeout 1s;
# proxy_timeout 3s;
proxy_pass ftp;
}

#FTP data
upstream ftpdata-v1 {
server z.z.z.z:60000 weight=5 max_fails=3 fail_timeout=30s;
}
upstream ftpdata-v2 {
server z.z.z.z:60001 weight=5 max_fails=3 fail_timeout=30s;
}
upstream ftpdata-p1 {
server z.z.z.z:60010 weight=5 max_fails=3 fail_timeout=30s;
}
upstream ftpdata-p2 {
server z.z.z.z:60011 weight=5 max_fails=3 fail_timeout=30s;
}

# vsftpd
server {
listen 60000;
proxy_connect_timeout 1s;
proxy_timeout 3s;
proxy_pass ftpdata-v1;
}
server {
listen 60001;
proxy_connect_timeout 1s;
proxy_timeout 3s;
proxy_pass ftpdata-v2;
}

# pure-ftpd
server {
listen 60010;
proxy_connect_timeout 1s;
proxy_timeout 3s;
proxy_pass ftpdata-p1;
}
server {
listen 60011;
proxy_connect_timeout 1s;
proxy_timeout 3s;
proxy_pass ftpdata-p2;
}

Amazon SESへのProxyで確認

「サーバ名がサーバが期待しているものと違っている」旨のエラーになったので、

メーラで「証明書を検証しない」設定が必要だった。

 

stream {

#SMTP
upstream smtp {
server email-smtp.us-west-2.amazonaws.com:587 weight=5 max_fails=3 fail_timeout=30s;
}

server {
listen 587;
proxy_connect_timeout 1s;
proxy_timeout 3s;
proxy_pass smtp;
}

upstream smtps {
server email-smtp.us-west-2.amazonaws.com:465 weight=5 max_fails=3 fail_timeout=30s;
}

server {
listen 465;
proxy_connect_timeout 1s;
proxy_timeout 3s;
proxy_pass smtps;
}

stream {
#FTP
upstream ftp {
server 127.0.0.1:21 weight=5 max_fails=3 fail_timeout=30s;
server 127.0.0.1:10021 weight=5 max_fails=3 fail_timeout=30s;
}

server {
listen 20021;
proxy_connect_timeout 1s;
proxy_timeout 3s;
proxy_pass ftp;
}

 

と思ったら、vsftpd/pureftpd共に、Passiveコマンドで失敗している

227 Entering Passive Mode (160,16,117,208,47,254)
421 Service not available, remote server has closed connection

 

vsftpdは以下設定で回避できたが、

pasv_promiscuous=yes

 

pure-ftpdは回避できるオプションがなさそう。