mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-01-19 08:19:15 +08:00
feat: 优化网站反向代理地址填写 (#1885)
This commit is contained in:
parent
7e5cdbf953
commit
fe705a25ea
@ -110,12 +110,13 @@ func (h *HostToolService) GetToolStatus(req request.HostToolReq) (*response.Host
|
|||||||
supervisorConfig.ConfigPath = args[cIndex+1]
|
supervisorConfig.ConfigPath = args[cIndex+1]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
if supervisorConfig.ConfigPath == "" {
|
||||||
configPath := "/etc/supervisord.conf"
|
configPath := "/etc/supervisord.conf"
|
||||||
if !fileOp.Stat(configPath) {
|
if !fileOp.Stat(configPath) {
|
||||||
configPath = "/etc/supervisor/supervisord.conf"
|
configPath = "/etc/supervisor/supervisord.conf"
|
||||||
if !fileOp.Stat(configPath) {
|
if fileOp.Stat(configPath) {
|
||||||
return nil, buserr.New("ErrConfigNotFound")
|
supervisorConfig.ConfigPath = configPath
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -343,6 +343,8 @@ export namespace Website {
|
|||||||
filePath?: string;
|
filePath?: string;
|
||||||
replaces?: ProxReplace;
|
replaces?: ProxReplace;
|
||||||
content?: string;
|
content?: string;
|
||||||
|
proxyAddress?: string;
|
||||||
|
proxyProtocol?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ProxReplace {
|
export interface ProxReplace {
|
||||||
|
@ -38,7 +38,15 @@
|
|||||||
<el-row :gutter="10">
|
<el-row :gutter="10">
|
||||||
<el-col :span="12">
|
<el-col :span="12">
|
||||||
<el-form-item :label="$t('website.proxyPass')" prop="proxyPass">
|
<el-form-item :label="$t('website.proxyPass')" prop="proxyPass">
|
||||||
<el-input v-model.trim="proxy.proxyPass"></el-input>
|
<el-input v-model.trim="proxy.proxyAddress" :placeholder="$t('website.proxyHelper')">
|
||||||
|
<template #prepend>
|
||||||
|
<el-select v-model="proxy.proxyProtocol" class="pre-select">
|
||||||
|
<el-option label="http" value="http://" />
|
||||||
|
<el-option label="https" value="https://" />
|
||||||
|
<el-option :label="$t('website.other')" value="" />
|
||||||
|
</el-select>
|
||||||
|
</template>
|
||||||
|
</el-input>
|
||||||
<div>
|
<div>
|
||||||
<span class="input-help">{{ $t('website.proxyPassHelper') }}</span>
|
<span class="input-help">{{ $t('website.proxyPassHelper') }}</span>
|
||||||
</div>
|
</div>
|
||||||
@ -131,10 +139,12 @@ const initData = (): Website.ProxyConfig => ({
|
|||||||
name: '',
|
name: '',
|
||||||
modifier: '^~',
|
modifier: '^~',
|
||||||
match: '/',
|
match: '/',
|
||||||
proxyPass: 'http://',
|
proxyPass: 'http://127.0.0.1:8080',
|
||||||
proxyHost: '$host',
|
proxyHost: '$host',
|
||||||
filePath: '',
|
filePath: '',
|
||||||
replaces: {},
|
replaces: {},
|
||||||
|
proxyAddress: '',
|
||||||
|
proxyProtocol: 'http://',
|
||||||
});
|
});
|
||||||
let proxy = ref(initData());
|
let proxy = ref(initData());
|
||||||
const replaces = ref<any>([]);
|
const replaces = ref<any>([]);
|
||||||
@ -148,6 +158,15 @@ const handleClose = () => {
|
|||||||
const acceptParams = (proxyParam: Website.ProxyConfig) => {
|
const acceptParams = (proxyParam: Website.ProxyConfig) => {
|
||||||
replaces.value = [];
|
replaces.value = [];
|
||||||
proxy.value = proxyParam;
|
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;
|
open.value = true;
|
||||||
if (proxy.value.replaces) {
|
if (proxy.value.replaces) {
|
||||||
for (const key in proxy.value.replaces) {
|
for (const key in proxy.value.replaces) {
|
||||||
@ -198,6 +217,7 @@ const submit = async (formEl: FormInstance | undefined) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
|
proxy.value.proxyPass = proxy.value.proxyProtocol + proxy.value.proxyAddress;
|
||||||
OperateProxyConfig(proxy.value)
|
OperateProxyConfig(proxy.value)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
if (proxy.value.operate == 'create') {
|
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({
|
defineExpose({
|
||||||
acceptParams,
|
acceptParams,
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user