nginx 作为ftp 服务存档文件
server {
listen 9988; #如果没有域名,端口就不能80
charset utf-8,gbk; #设置显示字符集
server_name 10.56.16.195;
location / {
root /home/simpleServer/; #指定ftp目录
autoindex on; #自动显示目录
autoindex_exact_size on; #显示文件大小,on 则表示打开显示文件的实际大小,单位是 bytes;off 关闭后显示文件的大概大小,单位为 KB 或者 MB 或者 GB
autoindex_localtime on; #显示文件时间,显示的文件时间为 GMT 时间,改为 on 后,显示的文件时间为文件的服务器时间
}
}
nginx 重定向问题
如nginx 配置location 如下:
location /zhcs/ {
proxy_pass https://10.56.16.203/;
}
当请求 http://ip:port/zhcs 的情况下,
nginx 会优先去寻找 location为/zhcs的配置, 发现寻找不到,会出发302,重定向到http://ip:port/zhcs/的配置,发现可以找到。
补充说明:
- nginx 会优先匹配location 完全一样的,然后在做近似匹配。
- http://ip:port/zhcs 这种URL属于资源请求
- http://ip:port/zhcs/ 最后有一个“/”的,属于目录请求, 目录请求,会去加载该目录下的index,html 文件