XNginx升级记录
之前的博文提到过,XNginx - nginx 集群可视化管理工具, 开发完成后一直稳定运行,直到前面因为一个站点的proxy站点配置问题,导致需要修改nginx 配置文件模板,因此借此机会对系统做了升级。
前端升级到最新版的ng-alain
事实证明,升级是痛苦的,前端项目真是一言难尽,能不动最好不动!
主要的变更是:
- 之前的simple-table变成了st
- desc也没了,成了sv,
- page-header等的action也需要显示的指定
查查文档,前后花了一个多小时,前端的升级真是太快了。。。
vhost增加default
通常会有类似下面的配置存在,通过default来标示是默认的配置:
server {
listen 80 default;
client_max_body_size 10240M;
location / {
proxy_pass http://proxy234648622.k8s_server;
proxy_set_header HOST $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
因此,这次给vhost增加了default选项,这样生成配置文件就可以加上default。

生成的配置文件:

SSL配置增加导入证书
之前SSL配置需要手动打开证书文件,拷贝文件内容到文本框,这次前端升级,增加了导入按钮,用户选择后直接读取证书文件.
实现很简单,使用nz-upload上传文件,通过nzBeforeUpload进行拦截,读取文件。
<div nz-col [nzSpan]="2" *ngIf="dto.enableSSL">
<nz-upload nzShowUploadList="false" [nzBeforeUpload]="readCertificate"><button nz-icon="upload" nz-button
nzType="nz-button.default" nzSize="small">导入</button> </nz-upload>
</div>
读取可以使用FileReader,记得return false。
readCertificate = (file: File) => {
const reader = new FileReader();
reader.readAsText(file);
this.dto.sslCertificate.commonName = file.name;
reader.onload = () => {
this.dto.sslCertificate.content = reader.result.toString();
}
return false;
}
导入已有配置文件
本次升级,在vhosts管理地方,增加了一个导入按钮,可以导入配置信息。

支持的方式是要求将配置文件及其相关资源,打包为zip,上传到系统后台进行解析, 接口代码:
@PostMapping("/importConfig/{groupId}")
@Timed
public String uploadConfFile(@RequestParam("file") MultipartFile file, @PathVariable String groupId) {
if (file.isEmpty()) {
return "Please select a file to upload";
}
if (!file.getContentType().equalsIgnoreCase("application/x-zip-compressed")) {
return "only support.zip";
}
File upFile = new File(new File(TEMP_FILE_PATH), System.currentTimeMillis() + file.getOriginalFilename());
try {
if(upFile.exists()){
upFile.delete();
}
file.transferTo(upFile);
} catch (IllegalStateException | IOException ex) {
return "upload error!";
}
try {
nginxConfigService.parseFromZipFile(upFile, groupId);
} catch (IOException e) {
return "upload error!";
}
return "success";
}
解析代码比较简单,先解压zip,然后找到nginx.conf,再调用上文提到的解析代码解析指令。
public void parseConfig(String confidDir, String groupId) {
// 查找nginx.conf
String nginxFile = searchForFile(new File(confidDir), "nginx.conf");
if (nginxFile.length() == 0) {
throw new RuntimeException("can't find nginx.conf,please make sure nginx.conf exist !");
}
List<Directive> directives = NginxConfParser.newBuilder().withConfigurationFile(nginxFile).parse();
directives.stream().forEach(directive -> {
if (directive instanceof ProxyDirective) {
saveUpStream((ProxyDirective) directive);
} else if (directive instanceof VirtualHostDirective) {
saveVHost((VirtualHostDirective) directive, groupId);
}
});
}
public void parseFromZipFile(File file, String groupId) throws IOException {
String tempDir = Paths.get(file.getPath()).getParent().toString() + File.separator + file.getName() + ".extract";
UnZipFile.unZipFiles(file, tempDir);
parseConfig(tempDir, groupId);
}
前后端项目合并到一起
之前前后端独立部署,如果项目足够大尚可,但是这个xnginx相对比较简单,独立部署费时费力,因此本次将前后端合并到一起
合并方法:
- 在backend新建一个webapp目录,将web代码放入
- 将web的相关配置文件拷贝到上层目录

然后修改angular.json、tsconfig.json 等包含路径的地址进行修改
"xnginx": {
"projectType": "application",
"root": "",
"sourceRoot": "webapp/src",
"prefix": "app",
"schematics": {
"@schematics/angular:component": {
"styleext": "less"
}
},
最后,修改angular.json的build配置,将构建结果保存到'target/classes/static',这样java项目打包时就能将前端资源带入:
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "target/classes/static",
"index": "webapp/src/index.html",
"main": "webapp/src/main.ts",
"tsConfig": "tsconfig.app.json",
"polyfills": "webapp/src/polyfills.ts",
"assets": [
"webapp/src/assets",
"webapp/src/favicon.ico"
],
"styles": [
"webapp/src/styles.less"
],
"scripts": [
"node_modules/@antv/g2/build/g2.js",
"node_modules/@antv/data-set/dist/data-set.min.js",
"node_modules/@antv/g2-plugin-slider/dist/g2-plugin-slider.min.js",
"node_modules/ajv/dist/ajv.bundle.js",
"node_modules/qrious/dist/qrious.min.js"
]
},
注意事项:
- 先构建前端,
npm run build - 再构建后端
mvn package -DskipTests
作者:Jadepeng
出处:jqpeng的技术记事本--http://www.cnblogs.com/xiaoqi
您的支持是对博主最大的鼓励,感谢您的认真阅读。
本文版权归作者所有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
XNginx升级记录的更多相关文章
- XUbuntu18.04(Bionic河狸)正式发布,系统安装升级记录
XUbuntu18.04(Bionic河狸)正式发布,系统安装升级记录 详细介绍: https://blog.pythonwood.com/2018/04/XUbuntu18.04(Bionic河狸) ...
- python-爬虫技能升级记录
====== python-爬虫技能升级记录 ====== ===== (一)感知爬虫及爬取流程 =====<code>从简单存取一个页面到 爬取到大量的定量数据,对技术要求更高,以百度百 ...
- vue-cli3.0 升级记录
年三十时 vue2.6 发布,向 3.0 看齐,说明 3.0 不远了.作为开发者也应该为vue3.0 做点准备.首先是把 vue-cli 升级到 3.x ,在这记录下 vue-cli2.x 升级 vu ...
- DailyMasalaCMS升级记录
手头上是一个比较老的工程,Jdk1.7 + Tomcat7.0 + Spring 3.x + Hibernate 3.x + Elasticseach 2.x 最近Elasticsearch升级,ja ...
- Kubernetes 升级记录:从 1.16.3 升级至 1.17.0
参考官方文档 Upgrading kubeadm clusters 在 ubuntu 18.04 上完成了升级,记录一下升级步骤. 一.升级第一个 master 节点 apt-get 安装 kubea ...
- Win7升级Win11升级记录及教程 【错误码(0×8004242d)】
hellow,大家好,我是公众号棱镜Prism K的[K君].家中电脑因为一些原因不得不进行升级,下面是我对这次电脑升级所进行的记录. step 1.打开微软官网,找到对应的WIN11下载模块,这里注 ...
- Windows 10 Threshold 2 升级记录
昨天(11月17日)升级到Windows 10 Threshold 2版本.我的使用的设备是Surface Pro 3,4G内存,128G硬盘. Threshold 2是作为一个Windows系统更新 ...
- Delphi XE4 Upate1 更新升级记录.
一直没时间,这两天折腾了一下 升级了. 其实也可能修了老bug 引入新bug. 呵呵. 看看Emb 都修了什么吧. 我干脆是重新安装的. 虽然官方也有一个单独的update.exe. 从这些bu ...
- Nginx的平滑升级记录---适用于编译安装的Nginx
一.查看自己的Nginx的版本号 [root@localhost sbin]# cd /usr/local/nginx/sbin/ [root@localhost sbin]# ls nginx [r ...
随机推荐
- List接口下的集合
集合框架 List接口下的集合特点: Set接口下的集合特点: 1.都是有序的 1.都是无序的 2.都有下标 2.没有下标 3.都可以重复 3.不可重复(覆盖) List接口下的集合 1.ArrayL ...
- gsoap使用
一. 安装gsoap 下载地址:http://sourceforge.net/projects/gsoap2/files/ 解压安装:./configure --prefix=/usr/local/g ...
- CodeForces1006E- Military Problem
E. Military Problem time limit per test 3 seconds memory limit per test 256 megabytes input standard ...
- SSM 轻量级框架构建:图书管理系统
一.接业务,作分析 1.大致业务要求 1.1 使用 SSM( Spring MVC + Spring + MyBatis )实现图书信息管理系统, MySQL5.5 作为后台数据库,该系统包括查询图书 ...
- Python爬虫实现抓取腾讯视频所有电影【实战必学】
2019-06-27 23:51:51 阅读数 407 收藏 更多 分类专栏: python爬虫 前言本文的文字及图片来源于网络,仅供学习.交流使用,不具有任何商业用途,版权归原作者所有,如有问 ...
- Spring Boot 外部化配置(一)- Environment、ConfigFileApplicationListener
目录 前言 1.起源 2.外部化配置的资源类型 3.外部化配置的核心 3.1 Environment 3.1.1.ConfigFileApplicationListener 3.1.2.关联 Spri ...
- shell脚本调用python模块
python helloworld.py代码为 # coding:utf-8 from __future__ import print_function import sys print(sys.pa ...
- CentOS 8安装
1.VMware workstation14Pro安装 下载蓝点网,序列号也有,直接输入,永久激活 2.CentOS8下载 CentOS8下载地址:清华源 3.CentOS8安装
- 【CSS】309- 复习 CSS盒模型
点击上方"前端自习课"关注,学习起来~ 一.概念 CSS盒模型本质上是一个盒子,封装周围的HTML元素,它包括:外边距(margin).边框(border).内边距(padding ...
- IPV6技术笔记(剖析IPv4toIPv6)
IPV6技术笔记 IPv6地址入门概念 什么是IPv6? IPv6,全称Internet Protocol version 6,即网际协议版本6,也叫互联网通信协议第六版.是互联网工程任务组(IETF ...