页面“Nginx二级目录Nginx制作下载站点”与“Alpine 修改docker的时区及安装telnet”之间的差异

来自linux中国网wiki
(页面间的差异)
跳到导航 跳到搜索
 
 
第1行: 第1行:
=nginx二级目录=
+
  [[category:Container]]
<pre>
+
=修改为cst 中国标准时间=
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>
 
<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   /etc/apk/repositories
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;
+
http://mirrors.aliyun.com/alpine/v3.12/main
        charset utf-8;
+
http://mirrors.aliyun.com/alpine/v3.12/community
 
  
 +
apk add --update nodejs npm
  
location /  {
+
#RUN 表明 这是在容器里面的
        autoindex on;
+
RUN apk add -U tzdata
        autoindex_exact_size on;
 
        autoindex_localtime on;
 
  
 +
#设置时区
 +
RUN cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
 +
  && echo 'Asia/Shanghai' >/etc/timezone
 +
</pre>
  
}
+
=安装telnet=
 
+
<pre>
 
+
#Alpine镜像中的telnet在3.7版本后被转移至busybox-extras包中
/usr/local/nginx/sbin/nginx -t
+
apk update
 
+
apk add busybox-extras
/usr/local/nginx/sbin/nginx -s reload
+
telnet smtp.163.com 25
 
 
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>
 
</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月28日 (一) 09:17的版本

修改为cst 中国标准时间


#修改源
cat   /etc/apk/repositories

http://mirrors.aliyun.com/alpine/v3.12/main
http://mirrors.aliyun.com/alpine/v3.12/community

apk add --update nodejs npm

#RUN 表明 这是在容器里面的
RUN apk add -U tzdata

#设置时区
RUN cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
  && echo 'Asia/Shanghai' >/etc/timezone

安装telnet

#Alpine镜像中的telnet在3.7版本后被转移至busybox-extras包中
apk update
apk add busybox-extras
telnet smtp.163.com 25