mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-01-31 14:08:06 +08:00
feat: 反代回源 SNI 支持设置 proxy_ssl_name (#6659)
Refs https://github.com/1Panel-dev/1Panel/issues/5960
This commit is contained in:
parent
047264dbbc
commit
e069db3c45
@ -175,21 +175,22 @@ type WebsiteUpdateDirPermission struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type WebsiteProxyConfig struct {
|
type WebsiteProxyConfig struct {
|
||||||
ID uint `json:"id" validate:"required"`
|
ID uint `json:"id" validate:"required"`
|
||||||
Operate string `json:"operate" validate:"required"`
|
Operate string `json:"operate" validate:"required"`
|
||||||
Enable bool `json:"enable" `
|
Enable bool `json:"enable" `
|
||||||
Cache bool `json:"cache" `
|
Cache bool `json:"cache" `
|
||||||
CacheTime int `json:"cacheTime" `
|
CacheTime int `json:"cacheTime" `
|
||||||
CacheUnit string `json:"cacheUnit"`
|
CacheUnit string `json:"cacheUnit"`
|
||||||
Name string `json:"name" validate:"required"`
|
Name string `json:"name" validate:"required"`
|
||||||
Modifier string `json:"modifier"`
|
Modifier string `json:"modifier"`
|
||||||
Match string `json:"match" validate:"required"`
|
Match string `json:"match" validate:"required"`
|
||||||
ProxyPass string `json:"proxyPass" validate:"required"`
|
ProxyPass string `json:"proxyPass" validate:"required"`
|
||||||
ProxyHost string `json:"proxyHost" validate:"required"`
|
ProxyHost string `json:"proxyHost" validate:"required"`
|
||||||
Content string `json:"content"`
|
Content string `json:"content"`
|
||||||
FilePath string `json:"filePath"`
|
FilePath string `json:"filePath"`
|
||||||
Replaces map[string]string `json:"replaces"`
|
Replaces map[string]string `json:"replaces"`
|
||||||
SNI bool `json:"sni"`
|
SNI bool `json:"sni"`
|
||||||
|
ProxySSLName string `json:"proxySSLName"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type WebsiteProxyReq struct {
|
type WebsiteProxyReq struct {
|
||||||
|
@ -1667,6 +1667,9 @@ func (w WebsiteService) OperateProxy(req request.WebsiteProxyConfig) (err error)
|
|||||||
}
|
}
|
||||||
if req.SNI {
|
if req.SNI {
|
||||||
location.UpdateDirective("proxy_ssl_server_name", []string{"on"})
|
location.UpdateDirective("proxy_ssl_server_name", []string{"on"})
|
||||||
|
if req.ProxySSLName != "" {
|
||||||
|
location.UpdateDirective("proxy_ssl_name", []string{req.ProxySSLName})
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
location.UpdateDirective("proxy_ssl_server_name", []string{"off"})
|
location.UpdateDirective("proxy_ssl_server_name", []string{"off"})
|
||||||
}
|
}
|
||||||
@ -1749,6 +1752,9 @@ func (w WebsiteService) GetProxies(id uint) (res []request.WebsiteProxyConfig, e
|
|||||||
if directive.GetName() == "proxy_ssl_server_name" {
|
if directive.GetName() == "proxy_ssl_server_name" {
|
||||||
proxyConfig.SNI = directive.GetParameters()[0] == "on"
|
proxyConfig.SNI = directive.GetParameters()[0] == "on"
|
||||||
}
|
}
|
||||||
|
if directive.GetName() == "proxy_ssl_name" {
|
||||||
|
proxyConfig.ProxySSLName = directive.GetParameters()[0]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
res = append(res, proxyConfig)
|
res = append(res, proxyConfig)
|
||||||
}
|
}
|
||||||
|
@ -11,4 +11,5 @@ location ^~ /test {
|
|||||||
add_header X-Cache $upstream_cache_status;
|
add_header X-Cache $upstream_cache_status;
|
||||||
add_header Cache-Control no-cache;
|
add_header Cache-Control no-cache;
|
||||||
proxy_ssl_server_name off;
|
proxy_ssl_server_name off;
|
||||||
|
proxy_ssl_name $proxy_host;
|
||||||
}
|
}
|
||||||
|
@ -373,6 +373,8 @@ export namespace Website {
|
|||||||
content?: string;
|
content?: string;
|
||||||
proxyAddress?: string;
|
proxyAddress?: string;
|
||||||
proxyProtocol?: string;
|
proxyProtocol?: string;
|
||||||
|
sni: boolean;
|
||||||
|
proxySSLName: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ProxReplace {
|
export interface ProxReplace {
|
||||||
|
@ -31,6 +31,9 @@
|
|||||||
<el-switch v-model="proxy.sni"></el-switch>
|
<el-switch v-model="proxy.sni"></el-switch>
|
||||||
<span class="input-help">{{ $t('website.sniHelper') }}</span>
|
<span class="input-help">{{ $t('website.sniHelper') }}</span>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
<el-form-item label="proxy_ssl_name" prop="proxySSLName" v-if="proxy.sni">
|
||||||
|
<el-input v-model.trim="proxy.proxySSLName"></el-input>
|
||||||
|
</el-form-item>
|
||||||
<el-form-item :label="$t('website.cacheTime')" prop="cacheTime" v-if="proxy.cache">
|
<el-form-item :label="$t('website.cacheTime')" prop="cacheTime" v-if="proxy.cache">
|
||||||
<el-input v-model.number="proxy.cacheTime" maxlength="15">
|
<el-input v-model.number="proxy.cacheTime" maxlength="15">
|
||||||
<template #append>
|
<template #append>
|
||||||
@ -47,7 +50,7 @@
|
|||||||
</el-form-item>
|
</el-form-item>
|
||||||
<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="proxyAddress">
|
||||||
<el-input
|
<el-input
|
||||||
v-model.trim="proxy.proxyAddress"
|
v-model.trim="proxy.proxyAddress"
|
||||||
:placeholder="$t('website.proxyHelper')"
|
:placeholder="$t('website.proxyHelper')"
|
||||||
@ -139,6 +142,7 @@ const rules = ref({
|
|||||||
cacheTime: [Rules.requiredInput, checkNumberRange(1, 65535)],
|
cacheTime: [Rules.requiredInput, checkNumberRange(1, 65535)],
|
||||||
proxyPass: [Rules.requiredInput],
|
proxyPass: [Rules.requiredInput],
|
||||||
proxyHost: [Rules.requiredInput],
|
proxyHost: [Rules.requiredInput],
|
||||||
|
proxyAddress: [Rules.requiredInput],
|
||||||
});
|
});
|
||||||
const open = ref(false);
|
const open = ref(false);
|
||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
@ -159,6 +163,8 @@ const initData = (): Website.ProxyConfig => ({
|
|||||||
replaces: {},
|
replaces: {},
|
||||||
proxyAddress: '',
|
proxyAddress: '',
|
||||||
proxyProtocol: 'http://',
|
proxyProtocol: 'http://',
|
||||||
|
sni: false,
|
||||||
|
proxySSLName: '$proxy_host',
|
||||||
});
|
});
|
||||||
let proxy = ref(initData());
|
let proxy = ref(initData());
|
||||||
const replaces = ref<any>([]);
|
const replaces = ref<any>([]);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user