mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-01-19 08:19:15 +08:00
fix: 解决删除HTTPS时候没有清除配置的问题
This commit is contained in:
parent
1fcc21839a
commit
0e6530f0cc
@ -126,7 +126,7 @@ func updateNginxConfig(scope string, params []dto.NginxParam, website *model.Web
|
||||
return nginxCheckAndReload(config.OldContent, config.FilePath, nginxFull.Install.ContainerName)
|
||||
}
|
||||
|
||||
func deleteNginxConfig(scope string, keys []string, website *model.Website) error {
|
||||
func deleteNginxConfig(scope string, params []dto.NginxParam, website *model.Website) error {
|
||||
nginxFull, err := getNginxFull(website)
|
||||
if err != nil {
|
||||
return err
|
||||
@ -144,8 +144,8 @@ func deleteNginxConfig(scope string, keys []string, website *model.Website) erro
|
||||
block = config.Config.Block
|
||||
}
|
||||
|
||||
for _, key := range keys {
|
||||
block.RemoveDirective(key, []string{})
|
||||
for _, param := range params {
|
||||
block.RemoveDirective(param.Name, param.Params)
|
||||
}
|
||||
|
||||
if err := nginx.WriteConfig(config.Config, nginx.IndentedStyle); err != nil {
|
||||
|
@ -455,7 +455,13 @@ func (w WebsiteService) UpdateNginxConfigByScope(req request.NginxConfigUpdate)
|
||||
return err
|
||||
}
|
||||
if req.Operate == constant.ConfigDel {
|
||||
return deleteNginxConfig(constant.NginxScopeServer, keys, &website)
|
||||
var nginxParams []dto.NginxParam
|
||||
for _, key := range keys {
|
||||
nginxParams = append(nginxParams, dto.NginxParam{
|
||||
Name: key,
|
||||
})
|
||||
}
|
||||
return deleteNginxConfig(constant.NginxScopeServer, nginxParams, &website)
|
||||
}
|
||||
params := getNginxParams(req.Params, keys)
|
||||
if req.Operate == constant.ConfigNew {
|
||||
@ -547,9 +553,12 @@ func (w WebsiteService) OpWebsiteHTTPS(ctx context.Context, req request.WebsiteH
|
||||
if err := deleteListenAndServerName(website, []int{443}, []string{}); err != nil {
|
||||
return response.WebsiteHTTPS{}, err
|
||||
}
|
||||
keys := getKeysFromStaticFile(dto.SSL)
|
||||
keys = append(keys, "if")
|
||||
if err := deleteNginxConfig(constant.NginxScopeServer, keys, &website); err != nil {
|
||||
nginxParams := getNginxParamsFromStaticFile(dto.SSL, nil)
|
||||
nginxParams = append(nginxParams, dto.NginxParam{
|
||||
Name: "if",
|
||||
Params: []string{"($scheme", "=", "http)"},
|
||||
})
|
||||
if err := deleteNginxConfig(constant.NginxScopeServer, nginxParams, &website); err != nil {
|
||||
return response.WebsiteHTTPS{}, err
|
||||
}
|
||||
if err := websiteRepo.Save(ctx, &website); err != nil {
|
||||
@ -771,7 +780,12 @@ func (w WebsiteService) OpWebsiteLog(req request.WebsiteLogReq) (*response.Websi
|
||||
key = "error_log"
|
||||
website.ErrorLog = false
|
||||
}
|
||||
if err := deleteNginxConfig(constant.NginxScopeServer, []string{key}, &website); err != nil {
|
||||
var nginxParams []dto.NginxParam
|
||||
nginxParams = append(nginxParams, dto.NginxParam{
|
||||
Name: key,
|
||||
})
|
||||
|
||||
if err := deleteNginxConfig(constant.NginxScopeServer, nginxParams, &website); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := websiteRepo.Save(context.Background(), &website); err != nil {
|
||||
|
@ -39,9 +39,11 @@ func (c *Config) FindHttp() *Http {
|
||||
|
||||
var repeatKeys = map[string]struct {
|
||||
}{
|
||||
"limit_conn": {},
|
||||
"limit_conn_zone": {},
|
||||
"set": {},
|
||||
"limit_conn": {},
|
||||
"limit_conn_zone": {},
|
||||
"set": {},
|
||||
"if": {},
|
||||
"proxy_set_header": {},
|
||||
}
|
||||
|
||||
func IsRepeatKey(key string) bool {
|
||||
|
@ -277,4 +277,5 @@ func (s *Server) AddHTTP2HTTPS() {
|
||||
})
|
||||
newDir.Block = block
|
||||
s.UpdateDirectiveBySecondKey("if", "($scheme", newDir)
|
||||
|
||||
}
|
||||
|
@ -1,3 +0,0 @@
|
||||
if ($server_port !~ 443){
|
||||
rewrite ^(/.*)$ https://$host$1 permanent;
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
server_names_hash_bucket_size 512;
|
||||
client_header_buffer_size 32k;
|
||||
client_max_body_size 50m;
|
||||
keepalive_timeout 60;
|
||||
|
||||
gzip on;
|
||||
gzip_min_length 1k;
|
||||
gzip_buffers 4 16k;
|
||||
gzip_http_version 1.1;
|
||||
gzip_comp_level 2;
|
||||
gzip_types text/plain application/javascript application/x-javascript text/javascript text/css application/xml;
|
||||
gzip_vary on;
|
||||
gzip_proxied expired no-cache no-store private auth;
|
||||
gzip_disable "MSIE [1-6]\.";
|
@ -7,9 +7,6 @@ import (
|
||||
//go:embed ssl.conf
|
||||
var SSL []byte
|
||||
|
||||
//go:embed http2https.conf
|
||||
var HTTPS []byte
|
||||
|
||||
//go:embed website_default.conf
|
||||
var WebsiteDefault []byte
|
||||
|
||||
@ -18,6 +15,3 @@ var Limit []byte
|
||||
|
||||
//go:embed index.html
|
||||
var Index []byte
|
||||
|
||||
//go:embed http_per.conf
|
||||
var HttpPer []byte
|
||||
|
@ -7,3 +7,4 @@ ssl_session_cache shared:SSL:10m;
|
||||
ssl_session_timeout 10m;
|
||||
add_header Strict-Transport-Security "max-age=31536000";
|
||||
error_page 497 https://$host$request_uri;
|
||||
proxy_set_header X-Forwarded-Proto https;
|
||||
|
@ -1,8 +1,6 @@
|
||||
<template>
|
||||
<el-tag :type="getType(status)" round effect="light">
|
||||
<!-- <span :style="{ color: getColor(status) }"> -->
|
||||
{{ $t('commons.status.' + status) }}
|
||||
<!-- </span> -->
|
||||
</el-tag>
|
||||
</template>
|
||||
|
||||
@ -17,17 +15,6 @@ const props = defineProps({
|
||||
});
|
||||
let status = ref('running');
|
||||
|
||||
// const getColor = (status: string) => {
|
||||
// switch (status) {
|
||||
// case 'running':
|
||||
// return '#00c957';
|
||||
// case 'error':
|
||||
// return '#ff0000';
|
||||
// default:
|
||||
// return '';
|
||||
// }
|
||||
// };
|
||||
|
||||
const getType = (status: string) => {
|
||||
switch (status) {
|
||||
case 'running':
|
||||
|
@ -3,9 +3,9 @@ import zh from './modules/zh';
|
||||
import en from './modules/en';
|
||||
|
||||
const i18n = createI18n({
|
||||
legacy: false, // 如果要支持 compositionAPI,此项必须设置为 false
|
||||
locale: 'zh', // 设置语言类型
|
||||
globalInjection: true, // 全局注册$t方法
|
||||
legacy: false,
|
||||
locale: 'zh',
|
||||
globalInjection: true,
|
||||
messages: {
|
||||
zh,
|
||||
en,
|
||||
|
@ -9,7 +9,7 @@ export const GlobalStore = defineStore({
|
||||
state: (): GlobalState => ({
|
||||
isLogin: false,
|
||||
csrfToken: '',
|
||||
assemblySize: 'small',
|
||||
assemblySize: 'default',
|
||||
language: '',
|
||||
themeConfig: {
|
||||
panelName: '',
|
||||
|
@ -1,6 +1,5 @@
|
||||
import { RouteRecordRaw } from 'vue-router';
|
||||
|
||||
/* themeConfigProp */
|
||||
export interface ThemeConfigProp {
|
||||
panelName: string;
|
||||
primary: string;
|
||||
@ -8,7 +7,6 @@ export interface ThemeConfigProp {
|
||||
footer: boolean;
|
||||
}
|
||||
|
||||
/* GlobalState */
|
||||
export interface GlobalState {
|
||||
isLogin: boolean;
|
||||
csrfToken: string;
|
||||
@ -22,7 +20,6 @@ export interface MenuState {
|
||||
menuList: RouteRecordRaw[];
|
||||
}
|
||||
|
||||
/* AuthState */
|
||||
export interface AuthState {
|
||||
authRouter: string[];
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user