linux之sftp服務器配置


1:添加sftp用戶

useradd admin
passwd admin

2:創建sftp文件夾路徑

mkdir -p /home/admin/data/file/ceshi

3:將sftp文件屬性修改成sftp用戶屬性及屬性組

chown -R admin:admin /home/admin/data/file/ceshi

4:修改ssh/sshd_config配置文件,在文件末尾添加如下參數

Match Group sftp ##匹配sftp組的用戶,如果要匹配多個組,多個組之間用逗號分割
ChrootDirectory/home/admin/data/file ##sftp主目錄指定到/var/www/html/upoads/ 
ForceCommand
internal-sftp ##指定sftp命令
AllowTcpForwarding no ##用戶不能使用端口轉發
X11Forwarding no ##用戶不能使用端口轉發

5:重啟sshd

systemctl restart sshd

6:測試鏈接

sftp admin@xxx.xxx.xxx.xxx

 

 7: 配置nginx進行代理

server{
        listen 8088;
        server_name localhost;
        charset     utf-8;
        client_max_body_size 175M;
        location / {
                root  /home/admin/date/file/ceshi;
                proxy_read_timeout 600;
                limit_rate_after 5m;
                limit_rate 1m;
                more_set_headers 'X-MyHeader: blah' 'X-MyHeader2: foo';
                more_set_headers -t 'text/plain text/css' 'Content-Type: video/mp4' 'Content-Type: video/flv' 'Content-Type: video/mp3' Content-Range: bytes 0-244/245 Content-245;
                more_set_headers -s '400 404 500 503' -s 413 'Foo: Bar';
#more_clear_headers 'Content-Type';
        }

        location ~ \.flv {
                root  /home/admin/date/file/ceshi;
                proxy_read_timeout 600;
                limit_rate_after 5m;
                limit_rate 1m;
                more_set_headers 'X-MyHeader: blah' 'X-MyHeader2: foo';
                more_set_headers -t 'text/plain text/css' 'Content-Type: video/mp4' 'Content-Type: video/flv' 'Content-Type: video/mp3' Content-Range: bytes 0-244/245 Content-245;
                more_set_headers -s '400 404 500 503' -s 413 'Foo: Bar';
        }
}

8:測試

 

 ##############################################################


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2026 CODEPRJ.COM