FTP服務器配置http訪問(配置nginx+ftp服務器)


一、搭建nginx服務器

先安裝nginx服務器

# yum install nginx -y

啟動nginx服務

# systemctl start nginx

瀏覽器訪問:http://192.168.1.55/

二、搭建FTP服務器

安裝ftp服務

# yum install vsftpd -y

啟動ftp服務

# systemctl start vsftpd

三、修改nginx配置文件

配置文件位於:/etc/nginx/nginx.conf,里面可以修改處理器數量、日志路徑、pid文件路徑等,默認的日志:

錯誤日志    /var/log/nginx/error.log
訪問日志    /var/log/nginx/access.log

在nginx.conf末尾有一句:include /etc/nginx/conf.d/*.conf;  推薦把用戶自己的配置放到conf.d/

下面把默認的server修改為一個簡單的文件服務器

# vi /etc/nginx/nginx.conf

user root;
worker_processes 1;
#error_log /var/log/nginx/error.log;
#pid /run/nginx.pid;

# Load dynamic modules. See /usr/share/nginx/README.dynamic.
#include /usr/share/nginx/modules/*.conf;

events {
    worker_connections 1024;
}

http {
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile            on;
    tcp_nopush          on;
    tcp_nodelay         on;
    keepalive_timeout   65;
    types_hash_max_size 2048;

    include             /etc/nginx/mime.types;
    default_type        application/octet-stream;

    # Load modular configuration files from the /etc/nginx/conf.d directory.
    # See http://nginx.org/en/docs/ngx_core_module.html#include
    # for more information.
    include /etc/nginx/conf.d/*.conf;

    server {
        listen       80 default_server;
        listen       [::]:80 default_server;
        server_name  _;
        root         /usr/share/nginx/html;

        # Load configuration files for the default server block.
        include /etc/nginx/default.d/*.conf;

        location / { root /var/ftp/pub/; autoindex on;  # 顯示目錄
autoindex_exact_size off; # 顯示文件大小
#默認為on顯示出文件的確切大小,單位是bytes
          #改為off后,顯示出文件的大概大小,單位是kB或者MB或者GB
autoindex_localtime on; # 顯示文件時間
#默認為off,顯示的文件時間為GMT時間
#改為on后,顯示的文件時間為文件的服務器時間
charset utf-8,gbk; #解決中文亂碼問題
}
error_page 404 /404.html; location = /40x.html { } error_page 500 502 503 504 /50x.html; location = /50x.html { } } # Settings for a TLS enabled server. # # server { # listen 443 ssl http2 default_server; # listen [::]:443 ssl http2 default_server; # server_name _; # root /usr/share/nginx/html; # # ssl_certificate "/etc/pki/nginx/server.crt"; # ssl_certificate_key "/etc/pki/nginx/private/server.key"; # ssl_session_cache shared:SSL:1m; # ssl_session_timeout 10m; # ssl_ciphers HIGH:!aNULL:!MD5; # ssl_prefer_server_ciphers on; # # # Load configuration files for the default server block. # include /etc/nginx/default.d/*.conf; # # location / { # } # # error_page 404 /404.html; # location = /40x.html { # } # # error_page 500 502 503 504 /50x.html; # location = /50x.html { # } # } }

重新啟動nginx

# systemctl restart nginx

瀏覽器訪問:http://192.168.1.55/

四、修改FTP配置文件

參考我的另一篇文章

配置允許匿名用戶登錄訪問vsftpd服務,進行文檔的上傳下載、文檔的新建刪除等操作

參考博客:

通過http協議訪問FTP服務器的搭建,ftp+nginx 圖片服務器搭建之后使用http訪問進行配置文件的修改

https://blog.csdn.net/weixin_41619143/article/details/91357577

通過HTTP服務訪問FTP服務器文件(配置nginx+ftp服務器)

https://blog.csdn.net/qq_37725650/article/details/80726828


免責聲明!

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



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