# ADF-VUE部署

# 修改部署脚本

修改文件:adf-vue\package.json,修改以下内容中的服务器地址

"publish": "scp -r dist/* root@43.143.65.220:/opt/idoc",

提醒

如果服务器中没有 /opt/idoc 目录,要先创建。

# 部署

在adf-vue根目录下执行命名:

pnpm build
pnpm run publish

# Nginx配置

# 安装Nginx

# 安装和启动

# nginx安装
yum install nginx
# 版本确认
nginx -v
# 自动启动设定
systemctl enable nginx
# 启动
systemctl start nginx

# Nginx基本命令

# 启动
systemctl start nginx
# 停止
systemctl stop nginx
# 重启
systemctl restart nginx
# 重新加载配置
nginx -s reload
# 确认状态
systemctl status nginx

# 配置

# 1、http的情况

# 删除 /etc/nginx/nginx.conf 文件里下方的这些默认配置:
server {
    listen       80;
    listen       [::]:80;
    server_name  _;
    root         /usr/share/nginx/html;

    # Load configuration files for the default server block.
    include /etc/nginx/default.d/*.conf;

    error_page 404 /404.html;
    location = /404.html {
    }

    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
    }
}
#/etc/nginx/conf.d/ 下新增配置文件 http.conf
server {
  listen       80;
  listen       [::]:80;
  server_name  _;

  # Load configuration files for the default server block.
  include /etc/nginx/default.d/*.conf;

	location /idoc {
  	# 不缓存html,防止程序更新后缓存继续生效
		if ($request_filename ~* .*\.(?:htm|html)$) {
			add_header Cache-Control "private, no-store, no-cache, must-revalidate, proxy-revalidate";
			access_log on;
		}
		try_files $uri $uri/ /idoc/index.html;
		alias /opt/idoc/;
		index index.html index.htm;
	}
	location /pdfjs {
		try_files $uri $uri/ /idoc/index.html;
		alias /opt/idoc/pdfjs/;
		index index.html index.htm;
	}
	location /jsconsole {
		try_files $uri $uri/ /idoc/index.html;
		alias /opt/idoc/jsconsole/;
		index index.html index.htm;
	}
	location /proxy/alfresco {
		proxy_pass http://127.0.0.1:8080/alfresco/service;
		proxy_set_header X-Real-IP $remote_addr;
		proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
		proxy_hide_header WWW-Authenticate;
		proxy_read_timeout 600;
	}
}
# 重新加载Nginx配置
nginx -s reload
# 浏览器访问:

http://${服务器IP地址}/idoc

# 2、https的情况

# 申请SSL证书,并上传到服务器

本例中域名为:demo.alfrescocn.com,放置证书位置为:/etc/nginx/cret/,后续在Nginx配置中需要指定域名和证书位置。

# 删除 /etc/nginx/nginx.conf 文件里下方的这些默认配置:
server {
    listen       80;
    listen       [::]:80;
    server_name  _;
    root         /usr/share/nginx/html;

    # Load configuration files for the default server block.
    include /etc/nginx/default.d/*.conf;

    error_page 404 /404.html;
    location = /404.html {
    }

    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
    }
}
#/etc/nginx/conf.d/ 下新增配置文件 https.conf

提醒

请根据实际情况修改域名和证书位置

server {
  listen 443 ssl;
  server_name demo.alfrescocn.com;
  proxy_set_header X-Real-IP $remote_addr;
  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  proxy_set_header Host $http_host;
  proxy_redirect off;
  client_max_body_size 0;
  proxy_max_temp_file_size 0;
  ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
  ssl_prefer_server_ciphers on;
  ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
  ssl_certificate      /etc/nginx/cret/demo.alfrescocn.com.pem;
  ssl_certificate_key  /etc/nginx/cret/demo.alfrescocn.com.key;

  location /idoc {
  	# 不缓存html,防止程序更新后缓存继续生效
		if ($request_filename ~* .*\.(?:htm|html)$) {
			add_header Cache-Control "private, no-store, no-cache, must-revalidate, proxy-revalidate";
			access_log on;
		}
		try_files $uri $uri/ /idoc/index.html;
		alias /opt/idoc/;
		index index.html index.htm;
	}
	location /pdfjs {
		try_files $uri $uri/ /idoc/index.html;
		alias /opt/idoc/pdfjs/;
		index index.html index.htm;
	}
	location /jsconsole {
		try_files $uri $uri/ /idoc/index.html;
		alias /opt/idoc/jsconsole/;
		index index.html index.htm;
	}

	location /proxy/alfresco {
		proxy_pass http://127.0.0.1:8080/alfresco/service;
		proxy_set_header X-Real-IP $remote_addr;
		proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
		proxy_hide_header WWW-Authenticate;
		proxy_read_timeout 600;
	}
	location /alfresco {
		proxy_pass http://127.0.0.1:8080/alfresco;
	}
	location /share {
		proxy_pass http://127.0.0.1:8080/share;
	}

}
# 重新加载Nginx配置
nginx -s reload
# 浏览器访问:

https://${域名}/idoc

更新时间: 2023年3月4日星期六晚上11点58分