diff --git a/backend/app/service/host_tool.go b/backend/app/service/host_tool.go index 5955231f4..0b8e743e0 100644 --- a/backend/app/service/host_tool.go +++ b/backend/app/service/host_tool.go @@ -110,12 +110,13 @@ func (h *HostToolService) GetToolStatus(req request.HostToolReq) (*response.Host supervisorConfig.ConfigPath = args[cIndex+1] } } - } else { + } + if supervisorConfig.ConfigPath == "" { configPath := "/etc/supervisord.conf" if !fileOp.Stat(configPath) { configPath = "/etc/supervisor/supervisord.conf" - if !fileOp.Stat(configPath) { - return nil, buserr.New("ErrConfigNotFound") + if fileOp.Stat(configPath) { + supervisorConfig.ConfigPath = configPath } } } diff --git a/frontend/src/api/interface/website.ts b/frontend/src/api/interface/website.ts index 752d57cc6..f89dcc1bb 100644 --- a/frontend/src/api/interface/website.ts +++ b/frontend/src/api/interface/website.ts @@ -343,6 +343,8 @@ export namespace Website { filePath?: string; replaces?: ProxReplace; content?: string; + proxyAddress?: string; + proxyProtocol?: string; } export interface ProxReplace { diff --git a/frontend/src/views/website/website/config/basic/proxy/create/index.vue b/frontend/src/views/website/website/config/basic/proxy/create/index.vue index f37c66b40..e4e9878cc 100644 --- a/frontend/src/views/website/website/config/basic/proxy/create/index.vue +++ b/frontend/src/views/website/website/config/basic/proxy/create/index.vue @@ -38,7 +38,15 @@ - + + +
{{ $t('website.proxyPassHelper') }}
@@ -131,10 +139,12 @@ const initData = (): Website.ProxyConfig => ({ name: '', modifier: '^~', match: '/', - proxyPass: 'http://', + proxyPass: 'http://127.0.0.1:8080', proxyHost: '$host', filePath: '', replaces: {}, + proxyAddress: '', + proxyProtocol: 'http://', }); let proxy = ref(initData()); const replaces = ref([]); @@ -148,6 +158,15 @@ const handleClose = () => { const acceptParams = (proxyParam: Website.ProxyConfig) => { replaces.value = []; proxy.value = proxyParam; + + const res = getProtocolAndHost(proxyParam.proxyPass); + if (res != null) { + proxy.value.proxyProtocol = res.protocol; + proxy.value.proxyAddress = res.host; + } else { + proxy.value.proxyProtocol = 'http://'; + } + open.value = true; if (proxy.value.replaces) { for (const key in proxy.value.replaces) { @@ -198,6 +217,7 @@ const submit = async (formEl: FormInstance | undefined) => { } } loading.value = true; + proxy.value.proxyPass = proxy.value.proxyProtocol + proxy.value.proxyAddress; OperateProxyConfig(proxy.value) .then(() => { if (proxy.value.operate == 'create') { @@ -213,6 +233,19 @@ const submit = async (formEl: FormInstance | undefined) => { }); }; +const getProtocolAndHost = (url: string): { protocol: string; host: string } | null => { + const regex = /^(https?:\/\/)([^\/]+)/; + const match = url.match(regex); + if (match) { + return { + protocol: match[1], + host: match[2], + }; + } + console.log('err'); + return null; +}; + defineExpose({ acceptParams, });