diff --git a/backend/app/api/v1/nginx.go b/backend/app/api/v1/nginx.go index ad8c23b5d..2ab222e1f 100644 --- a/backend/app/api/v1/nginx.go +++ b/backend/app/api/v1/nginx.go @@ -7,12 +7,12 @@ import ( "github.com/gin-gonic/gin" ) -// @Tags Nginx -// @Summary Load nginx conf -// @Description 获取 nginx 配置信息 +// @Tags OpenResty +// @Summary Load OpenResty conf +// @Description 获取 OpenResty 配置信息 // @Success 200 {object} response.FileInfo // @Security ApiKeyAuth -// @Router /nginx [get] +// @Router /openResty [get] func (b *BaseApi) GetNginx(c *gin.Context) { fileInfo, err := nginxService.GetNginxConfig() if err != nil { @@ -22,14 +22,14 @@ func (b *BaseApi) GetNginx(c *gin.Context) { helper.SuccessWithData(c, fileInfo) } -// @Tags Nginx -// @Summary Load partial nginx conf -// @Description 获取部分 nginx 配置信息 +// @Tags OpenResty +// @Summary Load partial OpenResty conf +// @Description 获取部分 OpenResty 配置信息 // @Accept json // @Param request body request.NginxScopeReq true "request" // @Success 200 {anrry} response.NginxParam // @Security ApiKeyAuth -// @Router /nginx/scope [post] +// @Router /openResty/scope [post] func (b *BaseApi) GetNginxConfigByScope(c *gin.Context) { var req request.NginxScopeReq if err := c.ShouldBindJSON(&req); err != nil { @@ -45,14 +45,14 @@ func (b *BaseApi) GetNginxConfigByScope(c *gin.Context) { helper.SuccessWithData(c, params) } -// @Tags Nginx -// @Summary Update nginx conf -// @Description 更新 nginx 配置信息 +// @Tags OpenResty +// @Summary Update OpenResty conf +// @Description 更新 OpenResty 配置信息 // @Accept json // @Param request body request.NginxConfigUpdate true "request" // @Success 200 // @Security ApiKeyAuth -// @Router /nginx/update [post] +// @Router /openResty/update [post] // @x-panel-log {"bodyKeys":["websiteId"],"paramKeys":[],"BeforeFuntions":[{"input_colume":"id","input_value":"websiteId","isList":false,"db":"websites","output_colume":"primary_domain","output_value":"domain"}],"formatZH":"更新 nginx 配置 [domain]","formatEN":"Update nginx conf [domain]"} func (b *BaseApi) UpdateNginxConfigByScope(c *gin.Context) { var req request.NginxConfigUpdate @@ -67,12 +67,12 @@ func (b *BaseApi) UpdateNginxConfigByScope(c *gin.Context) { helper.SuccessWithData(c, nil) } -// @Tags Nginx -// @Summary Load nginx status info -// @Description 获取 nginx 状态信息 +// @Tags OpenResty +// @Summary Load OpenResty status info +// @Description 获取 OpenResty 状态信息 // @Success 200 {object} response.NginxStatus // @Security ApiKeyAuth -// @Router /nginx/status [get] +// @Router /openResty/status [get] func (b *BaseApi) GetNginxStatus(c *gin.Context) { res, err := nginxService.GetStatus() if err != nil { @@ -82,14 +82,14 @@ func (b *BaseApi) GetNginxStatus(c *gin.Context) { helper.SuccessWithData(c, res) } -// @Tags Nginx -// @Summary Update nginx conf by upload file -// @Description 上传更新 nginx 配置文件 +// @Tags OpenResty +// @Summary Update OpenResty conf by upload file +// @Description 上传更新 OpenResty 配置文件 // @Accept json // @Param request body request.NginxConfigFileUpdate true "request" // @Success 200 // @Security ApiKeyAuth -// @Router /nginx/file [post] +// @Router /openResty/file [post] // @x-panel-log {"bodyKeys":[],"paramKeys":[],"BeforeFuntions":[],"formatZH":"更新 nginx 配置","formatEN":"Update nginx conf"} func (b *BaseApi) UpdateNginxFile(c *gin.Context) { var req request.NginxConfigFileUpdate diff --git a/backend/app/service/app_install.go b/backend/app/service/app_install.go index 83644f522..eab4dc456 100644 --- a/backend/app/service/app_install.go +++ b/backend/app/service/app_install.go @@ -324,7 +324,7 @@ func (a AppInstallService) DeleteCheck(installId uint) ([]dto.AppResource, error }) } } - if app.Key == constant.AppNginx { + if app.Key == constant.AppOpenresty { websites, _ := websiteRepo.GetBy() for _, website := range websites { res = append(res, dto.AppResource{ @@ -369,7 +369,7 @@ func (a AppInstallService) GetDefaultConfigByKey(key string) (string, error) { if key == constant.AppRedis { filePath = path.Join(filePath, "redis.conf") } - if key == constant.AppNginx { + if key == constant.AppOpenresty { filePath = path.Join(filePath, "nginx.conf") } contentByte, err := os.ReadFile(filePath) diff --git a/backend/app/service/nginx.go b/backend/app/service/nginx.go index 1d4024689..b7bb10257 100644 --- a/backend/app/service/nginx.go +++ b/backend/app/service/nginx.go @@ -19,11 +19,11 @@ type NginxService struct { } func (n NginxService) GetNginxConfig() (response.FileInfo, error) { - nginxInstall, err := getAppInstallByKey(constant.AppNginx) + nginxInstall, err := getAppInstallByKey(constant.AppOpenresty) if err != nil { return response.FileInfo{}, err } - configPath := path.Join(constant.AppInstallDir, constant.AppNginx, nginxInstall.Name, "conf", "nginx.conf") + configPath := path.Join(constant.AppInstallDir, constant.AppOpenresty, nginxInstall.Name, "conf", "nginx.conf") info, err := files.NewFileInfo(files.FileOption{ Path: configPath, Expand: true, @@ -95,7 +95,7 @@ func (n NginxService) UpdateConfigFile(req request.NginxConfigFileUpdate) error if err := fileOp.WriteFile(req.FilePath, strings.NewReader(req.Content), 0644); err != nil { return err } - nginxInstall, err := getAppInstallByKey(constant.AppNginx) + nginxInstall, err := getAppInstallByKey(constant.AppOpenresty) if err != nil { return err } diff --git a/backend/app/service/nginx_utils.go b/backend/app/service/nginx_utils.go index 7dd1f195f..9cb705d91 100644 --- a/backend/app/service/nginx_utils.go +++ b/backend/app/service/nginx_utils.go @@ -20,12 +20,12 @@ import ( func getNginxFull(website *model.Website) (dto.NginxFull, error) { var nginxFull dto.NginxFull - nginxInstall, err := getAppInstallByKey("nginx") + nginxInstall, err := getAppInstallByKey("openresty") if err != nil { return nginxFull, err } nginxFull.Install = nginxInstall - nginxFull.Dir = path.Join(constant.AppInstallDir, constant.AppNginx, nginxInstall.Name) + nginxFull.Dir = path.Join(constant.AppInstallDir, constant.AppOpenresty, nginxInstall.Name) nginxFull.ConfigDir = path.Join(nginxFull.Dir, "conf") nginxFull.ConfigFile = "nginx.conf" nginxFull.SiteDir = path.Join(nginxFull.Dir, "www") @@ -47,7 +47,7 @@ func getNginxFull(website *model.Website) (dto.NginxFull, error) { nginxFull.Website = *website var siteNginxConfig dto.NginxConfig nginxFileName := website.Alias + ".conf" - siteConfigPath := path.Join(constant.AppInstallDir, constant.AppNginx, nginxInstall.Name, "conf", "conf.d", nginxFileName) + siteConfigPath := path.Join(constant.AppInstallDir, constant.AppOpenresty, nginxInstall.Name, "conf", "conf.d", nginxFileName) siteNginxConfig.FilePath = siteConfigPath siteNginxContent, err := os.ReadFile(siteConfigPath) if err != nil { diff --git a/backend/app/service/website.go b/backend/app/service/website.go index cdf368372..56476ef23 100644 --- a/backend/app/service/website.go +++ b/backend/app/service/website.go @@ -293,11 +293,11 @@ func (w WebsiteService) GetWebsite(id uint) (response.WebsiteDTO, error) { } res.Website = website - nginxInstall, err := getAppInstallByKey(constant.AppNginx) + nginxInstall, err := getAppInstallByKey(constant.AppOpenresty) if err != nil { return res, err } - sitePath := path.Join(constant.AppInstallDir, constant.AppNginx, nginxInstall.Name, "www", "sites", website.Alias) + sitePath := path.Join(constant.AppInstallDir, constant.AppOpenresty, nginxInstall.Name, "www", "sites", website.Alias) res.ErrorLogPath = path.Join(sitePath, "log", "error.log") res.AccessLogPath = path.Join(sitePath, "log", "access.log") res.SitePath = sitePath @@ -468,7 +468,7 @@ func (w WebsiteService) GetWebsiteNginxConfig(websiteId uint) (response.FileInfo return response.FileInfo{}, err } - nginxApp, err := appRepo.GetFirst(appRepo.WithKey(constant.AppNginx)) + nginxApp, err := appRepo.GetFirst(appRepo.WithKey(constant.AppOpenresty)) if err != nil { return response.FileInfo{}, err } @@ -477,7 +477,7 @@ func (w WebsiteService) GetWebsiteNginxConfig(websiteId uint) (response.FileInfo return response.FileInfo{}, err } - configPath := path.Join(constant.AppInstallDir, constant.AppNginx, nginxInstall.Name, "conf", "conf.d", website.Alias+".conf") + configPath := path.Join(constant.AppInstallDir, constant.AppOpenresty, nginxInstall.Name, "conf", "conf.d", website.Alias+".conf") info, err := files.NewFileInfo(files.FileOption{ Path: configPath, @@ -619,7 +619,7 @@ func (w WebsiteService) PreInstallCheck(req request.WebsiteInstallCheckReq) ([]r showErr = false ) - app, err := appRepo.GetFirst(appRepo.WithKey(constant.AppNginx)) + app, err := appRepo.GetFirst(appRepo.WithKey(constant.AppOpenresty)) if err != nil { return nil, err } diff --git a/backend/app/service/website_ssl.go b/backend/app/service/website_ssl.go index 819ff2d0f..c1d745100 100644 --- a/backend/app/service/website_ssl.go +++ b/backend/app/service/website_ssl.go @@ -92,11 +92,11 @@ func (w WebsiteSSLService) Create(create request.WebsiteSSLCreate) (request.Webs return res, err } case constant.Http: - appInstall, err := getAppInstallByKey(constant.AppNginx) + appInstall, err := getAppInstallByKey(constant.AppOpenresty) if err != nil { return request.WebsiteSSLCreate{}, err } - if err := client.UseHTTP(path.Join(constant.AppInstallDir, constant.AppNginx, appInstall.Name, "root")); err != nil { + if err := client.UseHTTP(path.Join(constant.AppInstallDir, constant.AppOpenresty, appInstall.Name, "root")); err != nil { return res, err } } @@ -160,11 +160,11 @@ func (w WebsiteSSLService) Renew(sslId uint) error { return err } case constant.Http: - appInstall, err := getAppInstallByKey(constant.AppNginx) + appInstall, err := getAppInstallByKey(constant.AppOpenresty) if err != nil { return err } - if err := client.UseHTTP(path.Join(constant.AppInstallDir, constant.AppNginx, appInstall.Name, "root")); err != nil { + if err := client.UseHTTP(path.Join(constant.AppInstallDir, constant.AppOpenresty, appInstall.Name, "root")); err != nil { return err } } @@ -197,7 +197,7 @@ func (w WebsiteSSLService) Renew(sslId uint) error { } } if len(websites) > 0 { - nginxInstall, err := getAppInstallByKey(constant.AppNginx) + nginxInstall, err := getAppInstallByKey(constant.AppOpenresty) if err != nil { return err } diff --git a/backend/app/service/website_utils.go b/backend/app/service/website_utils.go index 2f8d1c50f..9aca634e5 100644 --- a/backend/app/service/website_utils.go +++ b/backend/app/service/website_utils.go @@ -51,12 +51,12 @@ func getDomain(domainStr string, websiteID uint) (model.WebsiteDomain, error) { } func createStaticHtml(website *model.Website) error { - nginxInstall, err := getAppInstallByKey(constant.AppNginx) + nginxInstall, err := getAppInstallByKey(constant.AppOpenresty) if err != nil { return err } - indexFolder := path.Join(constant.AppInstallDir, constant.AppNginx, nginxInstall.Name, "www", "sites", website.Alias, "index") + indexFolder := path.Join(constant.AppInstallDir, constant.AppOpenresty, nginxInstall.Name, "www", "sites", website.Alias, "index") indexPath := path.Join(indexFolder, "index.html") indexContent := string(nginx_conf.Index) fileOp := files.NewFileOp() @@ -77,7 +77,7 @@ func createStaticHtml(website *model.Website) error { } func createWebsiteFolder(nginxInstall model.AppInstall, website *model.Website) error { - nginxFolder := path.Join(constant.AppInstallDir, constant.AppNginx, nginxInstall.Name) + nginxFolder := path.Join(constant.AppInstallDir, constant.AppOpenresty, nginxInstall.Name) siteFolder := path.Join(nginxFolder, "www", "sites", website.Alias) fileOp := files.NewFileOp() if !fileOp.Stat(siteFolder) { @@ -109,7 +109,7 @@ func createWebsiteFolder(nginxInstall model.AppInstall, website *model.Website) } func configDefaultNginx(website *model.Website, domains []model.WebsiteDomain, appInstall *model.AppInstall) error { - nginxInstall, err := getAppInstallByKey(constant.AppNginx) + nginxInstall, err := getAppInstallByKey(constant.AppOpenresty) if err != nil { return err } @@ -118,7 +118,7 @@ func configDefaultNginx(website *model.Website, domains []model.WebsiteDomain, a } nginxFileName := website.Alias + ".conf" - configPath := path.Join(constant.AppInstallDir, constant.AppNginx, nginxInstall.Name, "conf", "conf.d", nginxFileName) + configPath := path.Join(constant.AppInstallDir, constant.AppOpenresty, nginxInstall.Name, "conf", "conf.d", nginxFileName) nginxContent := string(nginx_conf.WebsiteDefault) config := parser.NewStringParser(nginxContent).Parse() servers := config.FindServers() @@ -169,7 +169,7 @@ func configDefaultNginx(website *model.Website, domains []model.WebsiteDomain, a } func delNginxConfig(website model.Website, force bool) error { - nginxApp, err := appRepo.GetFirst(appRepo.WithKey(constant.AppNginx)) + nginxApp, err := appRepo.GetFirst(appRepo.WithKey(constant.AppOpenresty)) if err != nil { return err } @@ -182,7 +182,7 @@ func delNginxConfig(website model.Website, force bool) error { } nginxFileName := website.Alias + ".conf" - configPath := path.Join(constant.AppInstallDir, constant.AppNginx, nginxInstall.Name, "conf", "conf.d", nginxFileName) + configPath := path.Join(constant.AppInstallDir, constant.AppOpenresty, nginxInstall.Name, "conf", "conf.d", nginxFileName) fileOp := files.NewFileOp() if !fileOp.Stat(configPath) { @@ -191,7 +191,7 @@ func delNginxConfig(website model.Website, force bool) error { if err := fileOp.DeleteFile(configPath); err != nil { return err } - sitePath := path.Join(constant.AppInstallDir, constant.AppNginx, nginxInstall.Name, "www", "sites", website.PrimaryDomain) + sitePath := path.Join(constant.AppInstallDir, constant.AppOpenresty, nginxInstall.Name, "www", "sites", website.PrimaryDomain) if fileOp.Stat(sitePath) { _ = fileOp.DeleteDir(sitePath) } @@ -247,7 +247,7 @@ func deleteListenAndServerName(website model.Website, ports []int, domains []str } func createPemFile(website model.Website, websiteSSL model.WebsiteSSL) error { - nginxApp, err := appRepo.GetFirst(appRepo.WithKey(constant.AppNginx)) + nginxApp, err := appRepo.GetFirst(appRepo.WithKey(constant.AppOpenresty)) if err != nil { return err } @@ -256,7 +256,7 @@ func createPemFile(website model.Website, websiteSSL model.WebsiteSSL) error { return err } - configDir := path.Join(constant.AppInstallDir, constant.AppNginx, nginxInstall.Name, "www", "sites", website.Alias, "ssl") + configDir := path.Join(constant.AppInstallDir, constant.AppOpenresty, nginxInstall.Name, "www", "sites", website.Alias, "ssl") fileOp := files.NewFileOp() if !fileOp.Stat(configDir) { @@ -417,7 +417,7 @@ func handleWebsiteBackup(backupType, baseDir, backupDir, domain, backupName stri } global.LOG.Info("put website into tmp dir successful") - nginxInfo, err := appInstallRepo.LoadBaseInfo(constant.AppNginx, "") + nginxInfo, err := appInstallRepo.LoadBaseInfo(constant.AppOpenresty, "") if err != nil { return err } @@ -472,7 +472,7 @@ func handleWebsiteBackup(backupType, baseDir, backupDir, domain, backupName stri } func handleWebsiteRecover(website *model.Website, fileDir string) error { - nginxInfo, err := appInstallRepo.LoadBaseInfo(constant.AppNginx, "") + nginxInfo, err := appInstallRepo.LoadBaseInfo(constant.AppOpenresty, "") if err != nil { return err } @@ -566,7 +566,7 @@ func saveWebsiteJson(website *model.Website, tmpDir string) error { } func deleteWebsiteFolder(nginxInstall model.AppInstall, website *model.Website) error { - nginxFolder := path.Join(constant.AppInstallDir, constant.AppNginx, nginxInstall.Name) + nginxFolder := path.Join(constant.AppInstallDir, constant.AppOpenresty, nginxInstall.Name) siteFolder := path.Join(nginxFolder, "www", "sites", website.Alias) fileOp := files.NewFileOp() if fileOp.Stat(siteFolder) { diff --git a/backend/constant/app.go b/backend/constant/app.go index 3fa997f40..c50ad8934 100644 --- a/backend/constant/app.go +++ b/backend/constant/app.go @@ -12,9 +12,9 @@ const ( AppNormal = "Normal" AppTakeDown = "TakeDown" - AppNginx = "nginx" - AppMysql = "mysql" - AppRedis = "redis" + AppOpenresty = "openresty" + AppMysql = "mysql" + AppRedis = "redis" ) type AppOperate string diff --git a/backend/router/ro_nginx.go b/backend/router/ro_nginx.go index 48d3e6624..94012ada7 100644 --- a/backend/router/ro_nginx.go +++ b/backend/router/ro_nginx.go @@ -10,7 +10,7 @@ type NginxRouter struct { } func (a *NginxRouter) InitNginxRouter(Router *gin.RouterGroup) { - groupRouter := Router.Group("nginx") + groupRouter := Router.Group("openresty") groupRouter.Use(middleware.JwtAuth()).Use(middleware.SessionAuth()) baseApi := v1.ApiGroupApp.BaseApi diff --git a/frontend/src/api/modules/nginx.ts b/frontend/src/api/modules/nginx.ts index d966b3112..60f9c4807 100644 --- a/frontend/src/api/modules/nginx.ts +++ b/frontend/src/api/modules/nginx.ts @@ -3,21 +3,21 @@ import { File } from '../interface/file'; import { Nginx } from '../interface/nginx'; export const GetNginx = () => { - return http.get(`/nginx`); + return http.get(`/openresty`); }; export const GetNginxConfigByScope = (req: Nginx.NginxScopeReq) => { - return http.post(`/nginx/scope`, req); + return http.post(`/openresty/scope`, req); }; export const UpdateNginxConfigByScope = (req: Nginx.NginxConfigReq) => { - return http.post(`/nginx/update`, req); + return http.post(`/openresty/update`, req); }; export const GetNginxStatus = () => { - return http.get(`/nginx/status`); + return http.get(`/openresty/status`); }; export const UpdateNginxConfigFile = (req: Nginx.NginxFileUpdate) => { - return http.post(`/nginx/file`, req); + return http.post(`/openresty/file`, req); }; diff --git a/frontend/src/components/app-status/index.vue b/frontend/src/components/app-status/index.vue index 82a122972..4d25a4068 100644 --- a/frontend/src/components/app-status/index.vue +++ b/frontend/src/components/app-status/index.vue @@ -64,7 +64,7 @@ import { MsgSuccess } from '@/utils/message'; const props = defineProps({ appKey: { type: String, - default: 'nginx', + default: 'openresty', }, }); diff --git a/frontend/src/views/app-store/installed/index.vue b/frontend/src/views/app-store/installed/index.vue index 75d155784..016a17540 100644 --- a/frontend/src/views/app-store/installed/index.vue +++ b/frontend/src/views/app-store/installed/index.vue @@ -130,7 +130,7 @@ { openOperate(row, 'down'); }, + disabled: (row: any) => { + return row.status !== 'Running'; + }, }, { label: i18n.global.t('app.delete'), diff --git a/frontend/src/views/website/website/index.vue b/frontend/src/views/website/website/index.vue index a1281b55d..b37062df8 100644 --- a/frontend/src/views/website/website/index.vue +++ b/frontend/src/views/website/website/index.vue @@ -11,7 +11,7 @@