• Zfile部署以及Nginx方向代理端口转发


    Zfile简介

    此项目是一个在线文件目录的程序, 支持各种对象存储和本地存储, 使用定位是个人放常用工具下载, 或做公共的文件库. 不会向多账户方向开发.

    前端基于 h5ai 的原有功能使用 Vue 重新开发、后端采用 SpringBoot, 数据库采用内嵌数据库.

    预览地址: https://zfile.vip

    文档地址: https://docs.zfile.vip

    社区地址: https://bbs.zfile.vip

    github开源地址:https://github.com/zhaojun1998/zfile/

    z-file 安装

    安装java依赖

    # Debian/Ubuntu系统
    apt update
    apt install -y openjdk-8-jre-headless unzip
    

    下载项目

    下面命令中第一行表示默认安装到用户目录下: ~/zfile 下。

    对于 root 用户, ~ = /root, ~/zfile 表示在 /root/zfile 路径下。

    对于其他用户, ~ = /hone/用户名 表示在 /home/用户名/ 路径下。如对于 oracle 用户, ~/zfile 则表示安装在 /home/oracle/zfile 下。

    如需更改安装路径, 请自行修改,如 export ZFILE_INSTALL_PATH=/data/zfile,表示安装在 /data/zfile 路径下。

    export ZFILE_INSTALL_PATH=~/zfile
    mkdir -p $ZFILE_INSTALL_PATH && cd $ZFILE_INSTALL_PATH
    wget https://c.jun6.net/ZFILE/zfile-release.war
    unzip zfile-release.war && rm -rf zfile-release.war
    chmod +x $ZFILE_INSTALL_PATH/bin/*.sh
    

    常用命令

     ~/zfile/bin/start.sh       # 启动项目
     ~/zfile/bin/stop.sh        # 停止项目
     ~/zfile/bin/restart.sh     # 重启项目
    

    更新方式

    # 停止程序
    ~/zfile/bin/stop.sh
    # 删除安装文件夹 
    rm -rf ~/zfile
    
    # 重新下载安装最新版
    export ZFILE_INSTALL_PATH=~/zfile
    mkdir -p $ZFILE_INSTALL_PATH && cd $ZFILE_INSTALL_PATH
    wget https://c.jun6.net/ZFILE/zfile-release.war
    unzip zfile-release.war && rm -rf zfile-release.war
    chmod +x $ZFILE_INSTALL_PATH/bin/*.sh
    

    DEBUG 模式

    配置文件在~/zfile/WEB-INF/classes/application.yml

    开启 debug 模式后:

    1. 可以访问 http(s)://ip:port/h2-console ,使用内置的 h2 数据库控制台来维护数据库。
    2. 可以访问 http(s)://ip:port/debug/resetPwd,会将用户名强制重置为 admin,密码修改为 123456。

    在配置文件 application.yml 中 zfile -> debug 修改。

    NGINX 反向代理

    安装

    #注:以下命令切勿使用apt 卸载/安装!apt不能彻底卸载或者安装!
    #卸载之前安装nginx
    apt-get --purge remove nginx
    
    # 安装nginx
    apt-get install nginx
    #安装位置信息
    whereis nginx 
    #nginx: /usr/sbin/nginx /usr/lib/nginx /etc/nginx /usr/share/nginx /usr/share/man/man8/nginx.8.gz
    #nginx 配置信息地址:/etc/ngin
    

    配置

    主配置信息:/etc/nginx/nginx.conf

    修改倒数两行代码,若仅用nginx代理8080端口的话,可以注释掉最后一行;否则,可将sites-enabled内的default删除!

    user www-data;
    worker_processes auto;
    pid /run/nginx.pid;
    include /etc/nginx/modules-enabled/*.conf;
    
    events {
    	worker_connections 768;
    	# multi_accept on;
    }
    
    http {
    
    	##
    	# Basic Settings
    	##
    
    	sendfile on;
    	tcp_nopush on;
    	tcp_nodelay on;
    	keepalive_timeout 65;
    	types_hash_max_size 2048;
    	# server_tokens off;
    
    	# server_names_hash_bucket_size 64;
    	# server_name_in_redirect off;
    
    	include /etc/nginx/mime.types;
    	default_type application/octet-stream;
    
    	##
    	# SSL Settings
    	##
    
    	ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; # Dropping SSLv3, ref: POODLE
    	ssl_prefer_server_ciphers on;
    
    	##
    	# Logging Settings
    	##
    
    	access_log /var/log/nginx/access.log;
    	error_log /var/log/nginx/error.log;
    
    	##
    	# Gzip Settings
    	##
    
    	gzip on;
    
    	# gzip_vary on;
    	# gzip_proxied any;
    	# gzip_comp_level 6;
    	# gzip_buffers 16 8k;
    	# gzip_http_version 1.1;
    	# gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
    
    	##
    	# Virtual Host Configs
    	##
    
    	include /etc/nginx/conf.d/*.conf;
    	#include /etc/nginx/sites-enabled/*;
    }
    

    在conf.d文件下,随便新建一个a.conf

    server {
        listen       80;
        server_name  dazhutizi.top;
        #access_log logs/dazhutizi_top.log;
        #error_log logs/dazhutizi_top_error.log;
        
        location / {
            proxy_set_header Host $host;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_pass http://localhost:8080;
            proxy_set_header X-Real-IP $remote_addr;
        }
    }
    

    常用命令

    # 重新加载配置
    nginx -s reload
    # 查看nginx.service状态,按q退出
    systemctl status nginx
    # 关闭服务
    systemctl stop nginx
    #开启服务,若重启则,restart
    systemctl start nginx
    
    # 若报错如下,则说明nginx服务已经存在,已经占据端口80,可对其kill后重启
    nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
    #若报pid无法启动,则以下命令启动
    nginx -c /etc/nginx/nginx.conf
    
    # 注意!
    # 注意!
    # 注意!
    # 测试时,请新建一个无痕浏览器,默认浏览器会缓存静态html文件!在短时间内请求相同地址时,直接显示已缓存内容!!!!!!
    
    # nginx -h
    nginx version: nginx/1.18.0 (Ubuntu)
    Usage: nginx [-?hvVtTq] [-s signal] [-c filename] [-p prefix] [-g directives]
    
    Options:
      -?,-h         : this help
      -v            : show version and exit
      -V            : show version and configure options then exit
      -t            : test configuration and exit
      -T            : test configuration, dump it and exit
      -q            : suppress non-error messages during configuration testing
      -s signal     : send signal to a master process: stop, quit, reopen, reload
      -p prefix     : set prefix path (default: /usr/share/nginx/)
      -c filename   : set configuration file (default: /etc/nginx/nginx.conf)
      -g directives : set global directives out of configuration file
    
    
  • 相关阅读:
    robotium(及百度cafe)运行testcase之后程序挂起没有响应的原因调查及解决
    python——请求服务器(http请求和https请求)
    Django项目:CRM(客户关系管理系统)--65--55PerfectCRM实现CRM客户报名状态颜色变化
    Django项目:CRM(客户关系管理系统)--64--54PerfectCRM实现CRM客户报名链接
    Django项目:CRM(客户关系管理系统)--63--53PerfectCRM实现CRM客户报名流程缴费
    Django项目:CRM(客户关系管理系统)--62--52PerfectCRM实现CRM客户报名流程学生合同审核
    Django项目:CRM(客户关系管理系统)--60--50PerfectCRM实现CRM客户报名流程学生合同URL随机码
    Django项目:CRM(客户关系管理系统)--59--49PerfectCRM实现CRM客户报名流程学生合同表单验证
    Django项目:CRM(客户关系管理系统)--58--48PerfectCRM实现CRM客户报名流程学生合同
    Django项目:CRM(客户关系管理系统)--56--47PerfectCRM实现CRM客户报名流程01
  • 原文地址:https://www.cnblogs.com/auspice/p/16121947.html
Copyright © 2020-2023  润新知