mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-01-18 22:22:59 +08:00
feat: 网站主域名支持域名:端口 (#2410)
Refs https://github.com/1Panel-dev/1Panel/issues/2333
This commit is contained in:
parent
aa588205e9
commit
2624238354
@ -185,10 +185,12 @@ func (w WebsiteService) CreateWebsite(create request.WebsiteCreate) (err error)
|
||||
return err
|
||||
}
|
||||
defaultHttpPort := nginxInstall.HttpPort
|
||||
primaryDomainArray := strings.Split(create.PrimaryDomain, ":")
|
||||
primaryDomain := primaryDomainArray[0]
|
||||
|
||||
defaultDate, _ := time.Parse(constant.DateLayout, constant.DefaultDate)
|
||||
website := &model.Website{
|
||||
PrimaryDomain: create.PrimaryDomain,
|
||||
PrimaryDomain: primaryDomain,
|
||||
Type: create.Type,
|
||||
Alias: create.Alias,
|
||||
Remark: create.Remark,
|
||||
@ -263,9 +265,8 @@ func (w WebsiteService) CreateWebsite(create request.WebsiteCreate) (err error)
|
||||
website.RuntimeID = runtime.ID
|
||||
if runtime.Resource == constant.ResourceAppstore {
|
||||
var (
|
||||
req request.AppInstallCreate
|
||||
nginxInstall model.AppInstall
|
||||
install *model.AppInstall
|
||||
req request.AppInstallCreate
|
||||
install *model.AppInstall
|
||||
)
|
||||
reg, _ := regexp.Compile(`[^a-z0-9_-]+`)
|
||||
req.Name = reg.ReplaceAllString(strings.ToLower(create.PrimaryDomain), "")
|
||||
@ -273,10 +274,6 @@ func (w WebsiteService) CreateWebsite(create request.WebsiteCreate) (err error)
|
||||
req.Params = create.AppInstall.Params
|
||||
req.Params["IMAGE_NAME"] = runtime.Image
|
||||
req.AppContainerConfig = create.AppInstall.AppContainerConfig
|
||||
nginxInstall, err = getAppInstallByKey(constant.AppOpenresty)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
req.Params["PANEL_WEBSITE_DIR"] = path.Join(nginxInstall.GetPath(), "/www")
|
||||
tx, installCtx := getTxAndContext()
|
||||
install, err = NewIAppService().Install(installCtx, req)
|
||||
@ -301,9 +298,9 @@ func (w WebsiteService) CreateWebsite(create request.WebsiteCreate) (err error)
|
||||
}
|
||||
|
||||
var domains []model.WebsiteDomain
|
||||
domains = append(domains, model.WebsiteDomain{Domain: website.PrimaryDomain, Port: defaultHttpPort})
|
||||
otherDomainArray := strings.Split(create.OtherDomains, "\n")
|
||||
for _, domain := range otherDomainArray {
|
||||
domainArray := strings.Split(create.OtherDomains, "\n")
|
||||
domainArray = append(domainArray, create.PrimaryDomain)
|
||||
for _, domain := range domainArray {
|
||||
if domain == "" {
|
||||
continue
|
||||
}
|
||||
|
@ -225,6 +225,20 @@ const checkDomain = (rule: any, value: any, callback: any) => {
|
||||
}
|
||||
};
|
||||
|
||||
const checkDomainWithPort = (rule: any, value: any, callback: any) => {
|
||||
if (value === '' || typeof value === 'undefined' || value == null) {
|
||||
callback(new Error(i18n.global.t('commons.rule.domain')));
|
||||
} else {
|
||||
const reg =
|
||||
/^([\w\u4e00-\u9fa5\-\*]{1,100}\.){1,10}([\w\u4e00-\u9fa5\-]{1,24}|[\w\u4e00-\u9fa5\-]{1,24}\.[\w\u4e00-\u9fa5\-]{1,24})(:\d{1,5})?$/;
|
||||
if (!reg.test(value) && value !== '') {
|
||||
callback(new Error(i18n.global.t('commons.rule.domain')));
|
||||
} else {
|
||||
callback();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const checkIntegerNumber = (rule: any, value: any, callback: any) => {
|
||||
if (value === '' || typeof value === 'undefined' || value == null) {
|
||||
callback(new Error(i18n.global.t('commons.rule.integer')));
|
||||
@ -442,6 +456,7 @@ interface CommonRule {
|
||||
containerName: FormItemRule;
|
||||
disabledFunctions: FormItemRule;
|
||||
leechExts: FormItemRule;
|
||||
domainWithPort: FormItemRule;
|
||||
|
||||
paramCommon: FormItemRule;
|
||||
paramComplexity: FormItemRule;
|
||||
@ -626,4 +641,9 @@ export const Rules: CommonRule = {
|
||||
trigger: 'blur',
|
||||
validator: checkParamSimple,
|
||||
},
|
||||
domainWithPort: {
|
||||
required: true,
|
||||
validator: checkDomainWithPort,
|
||||
trigger: 'blur',
|
||||
},
|
||||
};
|
||||
|
@ -1542,6 +1542,7 @@ const message = {
|
||||
runDirHelper2: 'Please ensure that the secondary running directory is under the index directory',
|
||||
openrestryHelper:
|
||||
'OpenResty default HTTP port: {0} HTTPS port: {1}, which may affect website domain name access and HTTPS forced redirect',
|
||||
primaryDomainHelper: 'Support domain name: port',
|
||||
},
|
||||
php: {
|
||||
short_open_tag: 'Short tag support',
|
||||
|
@ -1465,6 +1465,7 @@ const message = {
|
||||
retainConfig: '是否保留 php-fpm.conf 和 php.ini 文件',
|
||||
runDirHelper2: '請確保二級運行目錄位於 index 目錄下',
|
||||
openrestryHelper: 'OpenResty 默認 HTTP 端口:{0} HTTPS 端口:{1},可能影響網站域名訪問和 HTTPS 強制跳轉',
|
||||
primaryDomainHelper: '支援網域:port',
|
||||
},
|
||||
php: {
|
||||
short_open_tag: '短標簽支持',
|
||||
|
@ -1465,6 +1465,7 @@ const message = {
|
||||
retainConfig: '是否保留 php-fpm.conf 和 php.ini 文件',
|
||||
runDirHelper2: '请确保二级运行目录位于 index 目录下',
|
||||
openrestryHelper: 'OpenResty 默认 HTTP 端口:{0} HTTPS 端口 :{1},可能影响网站域名访问和 HTTPS 强制跳转',
|
||||
primaryDomainHelper: '支持域名:端口',
|
||||
},
|
||||
php: {
|
||||
short_open_tag: '短标签支持',
|
||||
|
@ -246,6 +246,7 @@
|
||||
<el-input
|
||||
v-model.trim="website.primaryDomain"
|
||||
@input="changeAlias(website.primaryDomain)"
|
||||
:placeholder="$t('website.primaryDomainHelper')"
|
||||
></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('website.otherDomains')" prop="otherDomains">
|
||||
@ -364,7 +365,7 @@ const website = ref({
|
||||
proxyAddress: '',
|
||||
});
|
||||
const rules = ref<any>({
|
||||
primaryDomain: [Rules.domain],
|
||||
primaryDomain: [Rules.domainWithPort],
|
||||
alias: [Rules.linuxName],
|
||||
type: [Rules.requiredInput],
|
||||
webSiteGroupId: [Rules.requiredSelectBusiness],
|
||||
@ -504,7 +505,7 @@ const changeRuntime = (runID: number) => {
|
||||
if (item.id === runID) {
|
||||
runtimeResource.value = item.resource;
|
||||
if (item.resource === 'appstore') {
|
||||
getAppDetailByID(item.appDetailId);
|
||||
getAppDetailByID(item.appDetailID);
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -519,7 +520,7 @@ const getRuntimes = async () => {
|
||||
website.value.runtimeID = first.id;
|
||||
runtimeResource.value = first.resource;
|
||||
if (first.resource === 'appstore') {
|
||||
getAppDetailByID(first.appDetailId);
|
||||
getAppDetailByID(first.appDetailID);
|
||||
}
|
||||
}
|
||||
} catch (error) {}
|
||||
@ -583,7 +584,8 @@ const submit = async (formEl: FormInstance | undefined) => {
|
||||
};
|
||||
|
||||
const changeAlias = (value: string) => {
|
||||
website.value.alias = value;
|
||||
const domain = value.split(':')[0];
|
||||
website.value.alias = domain;
|
||||
};
|
||||
|
||||
function compareVersions(version1: string, version2: string): boolean {
|
||||
|
Loading…
Reference in New Issue
Block a user