Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lakernote
EasyAdmin
提交
f95e2ae5
E
EasyAdmin
项目概览
lakernote
/
EasyAdmin
9 个月 前同步成功
通知
14
Star
3
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
E
EasyAdmin
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
f95e2ae5
编写于
8月 25, 2021
作者:
lakernote
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
(新增)[整体](增加Nginx在线编辑ui)
上级
46c56f39
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
190 addition
and
0 deletion
+190
-0
file/nginx.conf
file/nginx.conf
+22
-0
src/main/java/com/laker/admin/module/sys/controller/NginxController.java
...om/laker/admin/module/sys/controller/NginxController.java
+54
-0
src/main/java/com/laker/admin/module/sys/pojo/NginxQo.java
src/main/java/com/laker/admin/module/sys/pojo/NginxQo.java
+9
-0
web/admin/view/system/nginx.html
web/admin/view/system/nginx.html
+105
-0
未找到文件。
file/nginx.conf
0 → 100644
浏览文件 @
f95e2ae5
worker_processes
1
;
http
{
server
{
# 端口号
listen
80
;
server_name
www.nginx.cn
;
location
/
{
proxy_pass
http://www.nginx.cn
;
proxy_set_header
Host
$host
;
proxy_set_header
X-Real-IP
$remote_addr
;
proxy_set_header
X-Forwarded-For
$proxy_add_x_forwarded_for
;
}
}
# 注释
server
{
listen
8444
;
server_name
localhost
;
location
/
{
proxy_pass
http://192.168.0.1
;
}
}
}
src/main/java/com/laker/admin/module/sys/controller/NginxController.java
0 → 100644
浏览文件 @
f95e2ae5
package
com.laker.admin.module.sys.controller
;
import
cn.hutool.core.date.DateUtil
;
import
cn.hutool.core.io.FileUtil
;
import
cn.hutool.core.util.StrUtil
;
import
com.github.odiszapc.nginxparser.NgxConfig
;
import
com.github.odiszapc.nginxparser.NgxDumper
;
import
com.laker.admin.framework.Response
;
import
com.laker.admin.module.sys.pojo.NginxQo
;
import
com.laker.admin.module.sys.service.ISysDeptService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
java.io.File
;
import
java.io.IOException
;
import
java.util.Date
;
/**
* <p>
* nginx前端控制器
* </p>
*
* @author laker
* @since 2021-08-11
*/
@RestController
@RequestMapping
(
"/sys/nginx"
)
public
class
NginxController
{
@Autowired
ISysDeptService
sysDeptService
;
@GetMapping
public
Response
get
(
@RequestParam
(
required
=
false
,
defaultValue
=
"file/nginx.conf"
)
String
path
)
{
NgxConfig
conf
=
null
;
try
{
conf
=
NgxConfig
.
read
(
path
);
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
return
Response
.
error
(
"500"
,
"路径错误:"
+
path
);
}
String
content
=
new
NgxDumper
(
conf
).
dump
();
return
Response
.
ok
(
content
);
}
@PostMapping
public
Response
update
(
@RequestBody
NginxQo
nginxQo
)
{
if
(
StrUtil
.
isBlank
(
nginxQo
.
getPath
()))
{
nginxQo
.
setPath
(
"file/nginx.conf"
);
}
FileUtil
.
rename
(
new
File
(
nginxQo
.
getPath
()),
"nginx.conf-bak-"
+
DateUtil
.
format
(
new
Date
(),
"yyyy-MM-dd-HH-mm-ss"
),
true
);
FileUtil
.
writeString
(
nginxQo
.
getContext
(),
new
File
(
nginxQo
.
getPath
()),
"utf-8"
);
return
Response
.
ok
();
}
}
\ No newline at end of file
src/main/java/com/laker/admin/module/sys/pojo/NginxQo.java
0 → 100644
浏览文件 @
f95e2ae5
package
com.laker.admin.module.sys.pojo
;
import
lombok.Data
;
@Data
public
class
NginxQo
{
private
String
path
;
private
String
context
;
}
\ No newline at end of file
web/admin/view/system/nginx.html
0 → 100644
浏览文件 @
f95e2ae5
<!DOCTYPE html>
<html>
<head>
<meta
charset=
"utf-8"
>
<title></title>
<link
href=
"../../component/pear/css/pear.css"
rel=
"stylesheet"
/>
</head>
<body
class=
"pear-container"
>
<div
class=
"layui-card"
>
<div
class=
"layui-card-body"
>
<div
class=
"layui-btn-group"
>
<button
type=
"button"
class=
"layui-btn"
>
校验
</button>
<button
type=
"button"
class=
"layui-btn "
>
启动
</button>
<button
type=
"button"
class=
"layui-btn"
>
停止
</button>
<button
type=
"button"
class=
"layui-btn"
>
热启动
</button>
</div>
</div>
<div
class=
"layui-card-body"
>
<form
class=
"layui-form"
action=
""
>
<div
class=
"layui-form-item"
style=
"width: 100%;"
>
<label
class=
"layui-form-label"
>
配置路径
</label>
<div
class=
"layui-input-inline"
style=
"width: 36%;"
>
<input
type=
"text"
name=
"path"
id=
"nginxConfPath"
autocomplete=
"off"
class=
"layui-input"
style=
"width: 99%;"
placeholder=
"请输入nginx配置文件路径"
lay-verify=
"title"
>
</div>
<button
type=
"button"
class=
"layui-btn"
id=
"getConf"
>
加载
</button>
<button
type=
"submit"
class=
"layui-btn"
lay-submit=
""
lay-filter=
"save"
>
保存
</button>
</div>
<div
class=
"layui-form-item adminj-sort-item"
id=
"did_1629876782412_1"
cpt_id=
"textarea"
style=
"width: 100%;"
>
<label
class=
"layui-form-label"
></label>
<div
class=
"layui-input-inline"
style=
"width: 66%;"
>
<textarea
id=
"nginxContent"
name=
"context"
class=
"layui-textarea"
style=
"width: 99%; height: 600px"
></textarea>
</div>
</div>
</form>
</div>
</div>
</body>
<script
src=
"../../component/layui/layui.js"
></script>
<script
src=
"../../component/pear/pear.js"
></script>
<script>
layui
.
use
([
'
easyAdmin
'
,
'
form
'
],
function
()
{
let
easyAdmin
=
layui
.
easyAdmin
;
var
$
=
layui
.
$
;
//使用jQuery 重点处
let
form
=
layui
.
form
;
getConfContent
();
$
(
"
#getConf
"
).
click
(
function
()
{
getConfContent
();
});
form
.
on
(
'
submit(save)
'
,
function
(
data
)
{
// 转换
easyAdmin
.
http
({
url
:
"
/sys/nginx
"
,
data
:
JSON
.
stringify
(
data
.
field
),
dataType
:
'
json
'
,
contentType
:
'
application/json
'
,
type
:
'
post
'
,
success
:
function
(
result
)
{
if
(
result
.
success
)
{
layer
.
msg
(
result
.
msg
,
{
icon
:
1
,
time
:
2000
,
area
:
[
'
100px
'
,
'
65px
'
],
content
:
"
保存成功
"
},
function
()
{
getConfContent
();
});
}
else
{
layer
.
msg
(
result
.
msg
,
{
icon
:
2
,
time
:
2000
,
area
:
[
'
220px
'
,
'
70px
'
]
}
);
}
}
})
return
false
;
});
function
getConfContent
()
{
var
nginxConfPath
=
$
(
'
#nginxConfPath
'
).
val
();
easyAdmin
.
httpGet
(
"
/sys/nginx?path=
"
+
nginxConfPath
,
function
(
res
)
{
if
(
res
.
success
)
{
$
(
'
#nginxContent
'
).
val
(
res
.
data
);
}
else
{
layer
.
msg
(
res
.
msg
,
{
icon
:
2
,
time
:
2000
,
area
:
[
'
230px
'
,
'
65px
'
]}
);
}
});
}
})
</script>
</html>
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录