FTP服务器配置http访问(配置nginx+ftp服务器) 配置允许匿名用户登录访问vsftpd服务,进行文档的上传下载、文档的新建删除等操作
最编程
2024-01-01 19:42:42
...
一、搭建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.****.net/weixin_41619143/article/details/91357577
通过HTTP服务访问FTP服务器文件(配置nginx+ftp服务器)
https://blog.****.net/qq_37725650/article/details/80726828
推荐阅读
-
Microsoft 365 新功能 Flash:离线时使用 OneDrive Web 应用程序-作为管理员,您可以使用概述的组策略控制离线模式的各个方面。 为组织中的用户启用此功能后,当用户访问 OneDrive for Web 时,将首次设置离线模式。OneDrive for Web 的用户文件元数据副本会安全地本地存储在用户的设备上。用户设备上的这些数据只能由该用户使用和访问。如果其他人在您的设备上登录,他们将无法使用设备上的本地数据。 用户设备上的安全本地网络服务器将处理用户在 OneDrive for Web 中对其文件执行的操作,如查看、排序、重命名、移动和复制,这些操作传统上需要由 OneDrive 云服务处理。通过消除网络在加载和使用 OneDrive for Web 时的瓶颈,可以快速、流畅地与用户文件进行交互,如加载文件和文件夹、排序、重命名、移动和重命名。即使用户离线、失去互联网连接或服务中断,所有这些操作也将继续运行。 - OneDrive 离线模式允许您在离线状态下通过浏览器、OneDrive PWA(渐进式 Web 应用程序)和 Microsoft Teams 在 OneDrive 上工作,从而提高在各种网络上的性能,并帮助减轻与处理大型文件集相关的限制。 - 目前,安装了 OneDrive Sync 应用程序的 Windows 设备(Windows 10 或更高版本)和 macOS 设备(macOS 12 Monterey 或更高版本)以及基于 Chromium 的浏览器(Microsoft Edge、Google Chrome)都支持 OneDrive 离线模式。 - 默认情况下,OneDrive 将为网络上的用户提供离线模式,用户和管理员都可以选择禁用 OneDrive 的离线模式。 - 脱机模式是针对每台设备的设置(为用户在网络*问 OneDrive 所使用的每台设备单独配置)。 - 数据会安全地存储在用户配置文件目录下的本地数据库中,并通过安全的本地主机 HTTP 服务器处理请求。离线模式由一个单独的后台进程(Microsoft.SharePoint.exe)支持。 - 开启离线模式后,用户将在网络上的 OneDrive 顶部导航栏看到一个新图标。 这将如何影响您的组织
-
go语言Socket编程-Socket编程 什么是Socket Socket,英文含义是插座、插孔,一般称之为套接字,用于描述IP地址和端口。可以实现不同程序间的数据通信。 Socket起源于Unix,而Unix基本哲学之一就是“一切皆文件”,都可以用“打开open –> 读写write/read –> 关闭close”模式来操作。Socket就是该模式的一个实现,网络的Socket数据传输是一种特殊的I/O,Socket也是一种文件描述符。Socket也具有一个类似于打开文件的函数调用:Socket,该函数返回一个整型的Socket描述符,随后的连接建立、数据传输等操作都是通过该Socket实现的。 套接字的内核实现较为复杂,不宜在学习初期深入学习,了解到如下结构足矣。 套接字通讯原理示意 在TCP/IP协议中,“IP地址+TCP或UDP端口号”唯一标识网络通讯中的一个进程。“IP地址+端口号”就对应一个socket。欲建立连接的两个进程各自有一个socket来标识,那么这两个socket组成的socket pair就唯一标识一个连接。因此可以用Socket来描述网络连接的一对一关系。 常用的Socket类型有两种:流式Socket(SOCK_STREAM)和数据报式Socket(SOCK_DGRAM)。流式是一种面向连接的Socket,针对于面向连接的TCP服务应用;数据报式Socket是一种无连接的Socket,对应于无连接的UDP服务应用。 网络应用程序设计模式 C/S模式 传统的网络应用设计模式,客户机(client)/服务器(server)模式。需要在通讯两端各自部署客户机和服务器来完成数据通信。 B/S模式 浏览器(Browser)/服务器(Server)模式。只需在一端部署服务器,而另外一端使用每台PC都默认配置的浏览器即可完成数据的传输。 优缺点 对于C/S模式来说,其优点明显。客户端位于目标主机上可以保证性能,将数据缓存至客户端本地,从而提高数据传输效率。且,一般来说客户端和服务器程序由一个开发团队创作,所以他们之间所采用的协议相对灵活。可以在标准协议的基础上根据需求裁剪及定制。例如,腾讯所采用的通信协议,即为ftp协议的修改剪裁版。 因此,传统的网络应用程序及较大型的网络应用程序都首选C/S模式进行开发。如,知名的网络游戏魔兽世界。3D画面,数据量庞大,使用C/S模式可以提前在本地进行大量数据的缓存处理,从而提高观感。 C/S模式的缺点也较突出。由于客户端和服务器都需要有一个开发团队来完成开发。工作量将成倍提升,开发周期较长。另外,从用户角度出发,需要将客户端安插至用户主机上,对用户主机的安全性构成威胁。这也是很多用户不愿使用C/S模式应用程序的重要原因。 B/S模式相比C/S模式而言,由于它没有独立的客户端,使用标准浏览器作为客户端,其工作开发量较小。只需开发服务器端即可。另外由于其采用浏览器显示数据,因此移植性非常好,不受平台限制。如早期的偷菜游戏,在各个平台上都可以完美运行。 B/S模式的缺点也较明显。由于使用第三方浏览器,因此网络应用支持受限。另外,没有客户端放到对方主机上,缓存数据不尽如人意,从而传输数据量受到限制。应用的观感大打折扣。第三,必须与浏览器一样,采用标准http协议进行通信,协议选择不灵活。 因此在开发过程中,模式的选择由上述各自的特点决定。根据实际需求选择应用程序设计模式。 简单的C/S模型通信 Server端:Listen函数 func Listen(network, address string) (Listener, error) network:选用的协议:TCP、UDP, 如:“tcp”或 “udp” address:IP地址+端口号, 如:“127.0.0.1:8000”或 “:8000” Listener 接口: type Listener interface { Accept (Conn, error) Close error Addr Addr } Conn 接口: type Conn interface { Read(b byte) (n int, err error) Write(b byte) (n int, err error) Close error LocalAddr Addr RemoteAddr Addr SetDeadline(t time.Time) error SetReadDeadline(t time.Time) error SetWriteDeadline(t time.Time) error } 参看 [<u>https://studygolang.com/pkgdoc</u>](https://studygolang.com/pkgdoc) 中文帮助文档中的demo: 示例代码:TCP服务器.go package main import ( "net" "fmt" ) func main { // 创建监听 listener, err:= net.Listen("tcp", ":8000") if err != nil { fmt.Println("listen err:", err) return } defer listener.Close // 主协程结束时,关闭listener fmt.Println("服务器等待客户端建立连接...") // 等待客户端连接请求 conn, err := listener.Accept if err != nil { fmt.Println("accept err:", err) return } defer conn.Close // 使用结束,断开与客户端链接 fmt.Println("客户端与服务器连接建立成功...") // 接收客户端数据 buf := make(byte, 1024) // 创建1024大小的缓冲区,用于read n, err := conn.Read(buf) if err != nil { fmt.Println("read err:", err) return } fmt.Println("服务器读到:", string(buf[:n])) // 读多少,打印多少。 }
-
FTP服务器配置http访问(配置nginx+ftp服务器) 配置允许匿名用户登录访问vsftpd服务,进行文档的上传下载、文档的新建删除等操作