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 ...
随机推荐
- ThreadLocal 源码解读
一.引入 public class Thread implements Runnable { /* 前面略 */ /* ThreadLocal values pertaining to this th ...
- 将Android手机打造成你的Python开发者桌面#华为云·寻找黑马程序员#
欢迎添加华为云小助手微信(微信号:HWCloud002 或 HWCloud003),输入关键字"加群",加入华为云线上技术讨论群:输入关键字"最新活动",获取华 ...
- mysql的安装及命令
1.先检查系统是否装有mysql rpm -qa | grep mysql 2.下载mysql的repo源 wget http://192.168.130.150/mysql5.7.26/my ...
- 求局域网内所有在线主机的ip
在一个局域网内,已知其中一台主机的ip为192.,子网掩码为255.,求所有其他在线主机的ip. shell 编码实现 #!/bin/bash netWorkIP=. ) do $netWorkIP$ ...
- 洛谷 题解 P2727 【01串 Stringsobits】
本蒟蒻又双叒叕被爆踩辣! P2727 01串 Stringsobits 其实只要理解了就会觉得这是个傻逼题! 这题给的标签是 dp,搜索,数论 但是可以用二分的思路做! Solution: 从最高位开 ...
- git 提交代码步骤
拉取服务器代码,避免覆盖他人代码 git pull 查看当前项目中有哪些文件被修改过 git status 提交代码至缓存 git add . 将代码提交到本地仓库中 git commit -m “提 ...
- openlayers4 入门开发系列结合 echarts4 实现散点图(附源码下载)
前言 openlayers4 官网的 api 文档介绍地址 openlayers4 api,里面详细的介绍 openlayers4 各个类的介绍,还有就是在线例子:openlayers4 官网在线例子 ...
- 基于 raft 协议的 RocketMQ DLedger 多副本日志复制设计原理
目录 1.RocketMQ DLedger 多副本日志复制流程图 1.1 RocketMQ DLedger 日志转发(append) 请求流程图 1.2 RocketMQ DLedger 日志仲裁流程 ...
- 松软科技Web课堂:JavaScript this 关键词
实例 var person = { firstName: "Bill", lastName : "Gates", id : 678, fullName : fu ...
- 一 UI基本的用法
1. UIView的基本用法 //打印屏幕的宽和高 CGRect screenBounds = [[UIScreen mainScreen] bounds]; NSLog(@"%f, %f& ...