centos7環境 nginx轉發ftp請求(親測可用)

無聊的人類WP發表於2020-11-26

1.安裝4個外掛

1)yum install gcc-c++
2)yum install -y pcre pcre-devel
3)yum install -y zlib zlib-devel
4)yum install -y openssl openssl-devel

2.從官網下載nginx安裝包並解壓安裝

5)使用rz 命令匯入nginx-1.19.5.tar.gz安裝包
6)解壓tar -zxvf nginx-1.19.5.tar.gz
7)cd nginx-1.19.5
8)./configure
9)./configure --with-stream
10)make
11)make install

3.修改nginx配置檔案

12)修改配置檔案vim /usr/local/nginx/conf/nginx.conf
注意:stream與http平級,127.0.0.1:21修改成真實的ftp地址,監聽的埠修改為請求nginx的埠

stream { 
	upstream ftp { 
		hash $remote_addr consistent; 
		server 127.0.0.1:21 max_fails=3 fail_timeout=30s; 
	} 
	server { 
		listen 90; 
		proxy_connect_timeout 1s; 
		proxy_timeout 3s; 
		proxy_pass ftp; 
	} 
}

4.啟動nginx服務

13)啟動、停止nginx
cd /usr/local/nginx/sbin/
./nginx
./nginx -s stop
./nginx -s quit
./nginx -s reload

相關文章