页面“每天一命令之echo”与“Nginx二级目录Nginx制作下载站点”之间的差异

来自linux中国网wiki
(页面间的差异)
跳到导航 跳到搜索
 
 
第1行: 第1行:
=echo=
+
=nginx二级目录=
==echo 回车换行==
 
 
<pre>
 
<pre>
echo -e '\n'
+
nginx 子目录  index 后面没 ; 会导致 刷新 404
  
-e:激活转义字符。使用-e选项时,若字符串中出现以下字符,则特别加以处理,而不会将它当成一般文字输出:
+
#可放最后面
 +
    location /admin/ {
 +
          alias /var/www/test-topen-hailuo/admin/;
 +
          index index.html;
 +
          try_files $uri $uri/ /admin/index.html;
 +
        }
  
?\a 发出警告声;
 
?\b 删除前一个字符;
 
?\c 最后不加上换行符号;
 
?\f 换行但光标仍旧停留在原来的位置;
 
?\n 换行且光标移至行首;
 
?\r 光标移至行首,但不换行;
 
?\t 插入tab;
 
?\v 与\f相同;
 
?\ 插入\字符;
 
?\nnn 插入nnn(八进制)所代表的ASCII字符;
 
 
</pre>
 
</pre>
  
[https://www.jianshu.com/p/6f328cfa898d echo命令的换行方法]
+
=安全的文件下载站点=
 +
<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 配置文件下载及在线浏览]
  
[https://blog.csdn.net/xukai871105/article/details/35834703  Linux学习笔记——如何使用echo指令向文件写入内容]
+
[[category:ops]] [[category:nginx]]
[[category:ops]]
 

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

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 配置文件下载及在线浏览