页面“Nginx制作下载站点”与“Nginx二级目录Nginx制作下载站点”之间的差异

来自linux中国网wiki
(页面间的差异)
跳到导航 跳到搜索
标签新重定向
 
 
第1行: 第1行:
#重定向 [[Nginx二级目录Nginx制作下载站点]]
+
=nginx二级目录=
 +
<pre>
 +
nginx 子目录  index 后面没 ; 会导致 刷新 404;  注意 alias这一行的最后面 要有 /  不然 会403的
 +
 
 +
#可放最后面
 +
    location /admin/ {
 +
          alias /var/www/test-topen-hailuo/admin/;
 +
          index index.html;
 +
          try_files $uri $uri/ /admin/index.html;
 +
        }
 +
 
 +
</pre>
 +
 
 +
=安全的文件下载站点=
 +
<pre>
 +
      location /file/ {
 +
          alias /home/love/files/im/;
 +
      }
 +
</pre>
 +
visa url/file/logo.png
 +
=trouble=
 +
有时老是 403 解决办法 1 用root 运行nginx 2 看一下文件的家目录用户 是哪个 如果文件的家目录是evan 建议nginx用户 也是evan
 +
 
 +
=start=
 +
<pre>
 +
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/
 +
</pre>
 +
 
 +
=see also=
 +
[https://www.cnblogs.com/llody/p/10869689.html 使用Nginx制作下载站点]
 +
 
 +
[https://cloud.tencent.com/info/72959727b73eef0285178c1559e41b12.html nginx 配置文件下载及在线浏览]
 +
 
 +
[[category:ops]] [[category:nginx]]

2020年9月14日 (一) 03:35的版本

nginx二级目录

 
nginx 子目录   index 后面没 ; 会导致 刷新 404;  注意 alias这一行的最后面 要有 /  不然 会403的

#可放最后面
    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 配置文件下载及在线浏览