enhance: removed the ability to modify nginx log path settings online

This commit is contained in:
Jacky 2024-10-08 10:27:20 +08:00
parent abd76ff930
commit 27f751671b
No known key found for this signature in database
GPG key ID: 215C21B10DF38B4D
4 changed files with 9 additions and 8 deletions

View file

@ -3,6 +3,7 @@ package settings
import ( import (
"github.com/0xJacky/Nginx-UI/api" "github.com/0xJacky/Nginx-UI/api"
"github.com/0xJacky/Nginx-UI/internal/cron" "github.com/0xJacky/Nginx-UI/internal/cron"
"github.com/0xJacky/Nginx-UI/internal/nginx"
"github.com/0xJacky/Nginx-UI/settings" "github.com/0xJacky/Nginx-UI/settings"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"net/http" "net/http"
@ -15,6 +16,8 @@ func GetServerName(c *gin.Context) {
} }
func GetSettings(c *gin.Context) { func GetSettings(c *gin.Context) {
settings.NginxSettings.AccessLogPath = nginx.GetAccessLogPath()
settings.NginxSettings.ErrorLogPath = nginx.GetErrorLogPath()
c.JSON(http.StatusOK, gin.H{ c.JSON(http.StatusOK, gin.H{
"server": settings.ServerSettings, "server": settings.ServerSettings,
"nginx": settings.NginxSettings, "nginx": settings.NginxSettings,

View file

@ -14,7 +14,7 @@ const errors: Record<string, Record<string, string>> = inject('errors') as Recor
? $gettext('File not found') ? $gettext('File not found')
: ''" : ''"
> >
<AInput v-model:value="data.nginx.access_log_path" /> {{ data.nginx.access_log_path }}
</AFormItem> </AFormItem>
<AFormItem <AFormItem
:label="$gettext('Nginx Error Log Path')" :label="$gettext('Nginx Error Log Path')"
@ -23,7 +23,7 @@ const errors: Record<string, Record<string, string>> = inject('errors') as Recor
? $gettext('File not found') ? $gettext('File not found')
: ''" : ''"
> >
<AInput v-model:value="data.nginx.error_log_path" /> {{ data.nginx.error_log_path }}
</AFormItem> </AFormItem>
</AForm> </AForm>
</template> </template>

View file

@ -33,12 +33,10 @@ func GetConfPath(dir ...string) (confPath string) {
} }
joined := filepath.Clean(filepath.Join(confPath, filepath.Join(dir...))) joined := filepath.Clean(filepath.Join(confPath, filepath.Join(dir...)))
if !helper.IsUnderDirectory(joined, confPath) {
if !helper.IsUnderDirectory(confPath, joined) {
return confPath return confPath
} }
return joined
return
} }
func GetPIDPath() (path string) { func GetPIDPath() (path string) {

View file

@ -1,8 +1,8 @@
package settings package settings
type Nginx struct { type Nginx struct {
AccessLogPath string `json:"access_log_path" binding:"omitempty,file"` AccessLogPath string `json:"access_log_path" protected:"true"`
ErrorLogPath string `json:"error_log_path" binding:"omitempty,file"` ErrorLogPath string `json:"error_log_path" protected:"true"`
ConfigDir string `json:"config_dir" protected:"true"` ConfigDir string `json:"config_dir" protected:"true"`
PIDPath string `json:"pid_path" protected:"true"` PIDPath string `json:"pid_path" protected:"true"`
TestConfigCmd string `json:"test_config_cmd" protected:"true"` TestConfigCmd string `json:"test_config_cmd" protected:"true"`