Nginx二级目录Nginx制作下载站点

来自linux中国网wiki
跳到导航 跳到搜索

nginx二级目录

nginx 子目录   index 后面没 ; 会导致 刷新 404

#可放最后面
    location /admin/ {
          alias /var/www/test-topen-hailuo/admin/;
          index index.html;
          try_files $uri $uri/ /admin/index.html;
        }

安全的文件下载站点

       location /file/ {
          alias /home/love/files/im/;
       }

visa url/file/logo.png

trouble

有时老是 403 解决办法 1 用root 运行nginx 2 看一下文件的家目录用户 是哪个 如果文件的家目录是evan 建议nginx用户 也是evan

start

cat bcb-down.llia.net.conf
server {
       listen 80;
       server_name bcb-down.llia.net;
       access_log  /var/log/nginx/1static_ecosystem.log;
       client_max_body_size 10m;

        root  /home/f14;
        charset utf-8;
 


location /  {
        autoindex on;
        autoindex_exact_size on;
        autoindex_localtime on;


}


/usr/local/nginx/sbin/nginx -t

/usr/local/nginx/sbin/nginx -s reload

NAT VM 

 sites]# cat    bcb-down.lliao.net.conf
server
{
    listen 80;
    server_name bcb-down.lli.net;

    location / {
      proxy_pass http://192.168.11.245:80; #转发地址:端口 #写错了IP  哈哈  许总作了泛DNS
      proxy_http_version 1.1;
      proxy_set_header Host             $host;
      proxy_set_header X-Real-IP        $remote_addr;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection "upgrade";
    }
}

 bash -x   docker_reload_nginx.sh

 cat   docker_reload_nginx.sh
#!/bin/sh
#author:chunk
#date:2019-07-22
#docker reload nginx
echo "==================== start docker reload nginx =========================="

docker exec -it dockerforservices_nginx_1 sh -c "nginx -t && nginx -s reload"


外网用4g打不开 原来是自己写错IP了 
http://bcb-down.lliao.net/

see also

使用Nginx制作下载站点

nginx 配置文件下载及在线浏览