mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-02-07 17:10:07 +08:00
feat: 网站增加 IPV6 监听设置 (#1188)
This commit is contained in:
parent
4b3c9419f3
commit
a48ea497b0
@ -18,6 +18,7 @@ type WebsiteCreate struct {
|
|||||||
OtherDomains string `json:"otherDomains"`
|
OtherDomains string `json:"otherDomains"`
|
||||||
Proxy string `json:"proxy"`
|
Proxy string `json:"proxy"`
|
||||||
WebsiteGroupID uint `json:"webSiteGroupID" validate:"required"`
|
WebsiteGroupID uint `json:"webSiteGroupID" validate:"required"`
|
||||||
|
IPV6 bool `json:"IPV6"`
|
||||||
|
|
||||||
AppType string `json:"appType" validate:"oneof=new installed"`
|
AppType string `json:"appType" validate:"oneof=new installed"`
|
||||||
AppInstall NewAppInstall `json:"appInstall"`
|
AppInstall NewAppInstall `json:"appInstall"`
|
||||||
@ -51,6 +52,7 @@ type WebsiteUpdate struct {
|
|||||||
Remark string `json:"remark"`
|
Remark string `json:"remark"`
|
||||||
WebsiteGroupID uint `json:"webSiteGroupID" validate:"required"`
|
WebsiteGroupID uint `json:"webSiteGroupID" validate:"required"`
|
||||||
ExpireDate string `json:"expireDate"`
|
ExpireDate string `json:"expireDate"`
|
||||||
|
IPV6 bool `json:"IPV6"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type WebsiteDelete struct {
|
type WebsiteDelete struct {
|
||||||
|
@ -19,6 +19,7 @@ type Website struct {
|
|||||||
ErrorLog bool `json:"errorLog"`
|
ErrorLog bool `json:"errorLog"`
|
||||||
AccessLog bool `json:"accessLog"`
|
AccessLog bool `json:"accessLog"`
|
||||||
DefaultServer bool `json:"defaultServer"`
|
DefaultServer bool `json:"defaultServer"`
|
||||||
|
IPV6 bool `json:"IPV6"`
|
||||||
Rewrite string `gorm:"type:varchar" json:"rewrite"`
|
Rewrite string `gorm:"type:varchar" json:"rewrite"`
|
||||||
|
|
||||||
WebsiteGroupID uint `gorm:"type:integer" json:"webSiteGroupId"`
|
WebsiteGroupID uint `gorm:"type:integer" json:"webSiteGroupId"`
|
||||||
|
@ -176,6 +176,7 @@ func (w WebsiteService) CreateWebsite(create request.WebsiteCreate) (err error)
|
|||||||
SiteDir: "/",
|
SiteDir: "/",
|
||||||
AccessLog: true,
|
AccessLog: true,
|
||||||
ErrorLog: true,
|
ErrorLog: true,
|
||||||
|
IPV6: create.IPV6,
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -340,6 +341,8 @@ func (w WebsiteService) UpdateWebsite(req request.WebsiteUpdate) error {
|
|||||||
website.PrimaryDomain = req.PrimaryDomain
|
website.PrimaryDomain = req.PrimaryDomain
|
||||||
website.WebsiteGroupID = req.WebsiteGroupID
|
website.WebsiteGroupID = req.WebsiteGroupID
|
||||||
website.Remark = req.Remark
|
website.Remark = req.Remark
|
||||||
|
website.IPV6 = req.IPV6
|
||||||
|
|
||||||
if req.ExpireDate != "" {
|
if req.ExpireDate != "" {
|
||||||
expireDate, err := time.Parse(constant.DateLayout, req.ExpireDate)
|
expireDate, err := time.Parse(constant.DateLayout, req.ExpireDate)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -190,6 +190,9 @@ func configDefaultNginx(website *model.Website, domains []model.WebsiteDomain, a
|
|||||||
for _, domain := range domains {
|
for _, domain := range domains {
|
||||||
serverNames = append(serverNames, domain.Domain)
|
serverNames = append(serverNames, domain.Domain)
|
||||||
server.UpdateListen(strconv.Itoa(domain.Port), false)
|
server.UpdateListen(strconv.Itoa(domain.Port), false)
|
||||||
|
if website.IPV6 {
|
||||||
|
server.UpdateListen("[::]:"+strconv.Itoa(domain.Port), false)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
server.UpdateServerName(serverNames)
|
server.UpdateServerName(serverNames)
|
||||||
|
|
||||||
@ -291,6 +294,9 @@ func addListenAndServerName(website model.Website, ports []int, domains []string
|
|||||||
server := config.FindServers()[0]
|
server := config.FindServers()[0]
|
||||||
for _, port := range ports {
|
for _, port := range ports {
|
||||||
server.AddListen(strconv.Itoa(port), false)
|
server.AddListen(strconv.Itoa(port), false)
|
||||||
|
if website.IPV6 {
|
||||||
|
server.UpdateListen("[::]:"+strconv.Itoa(port), false)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
for _, domain := range domains {
|
for _, domain := range domains {
|
||||||
server.AddServerName(domain)
|
server.AddServerName(domain)
|
||||||
@ -311,6 +317,9 @@ func deleteListenAndServerName(website model.Website, binds []string, domains []
|
|||||||
server := config.FindServers()[0]
|
server := config.FindServers()[0]
|
||||||
for _, bind := range binds {
|
for _, bind := range binds {
|
||||||
server.DeleteListen(bind)
|
server.DeleteListen(bind)
|
||||||
|
if website.IPV6 {
|
||||||
|
server.DeleteListen("[::]:" + bind)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
for _, domain := range domains {
|
for _, domain := range domains {
|
||||||
server.DeleteServerName(domain)
|
server.DeleteServerName(domain)
|
||||||
@ -372,6 +381,9 @@ func applySSL(website model.Website, websiteSSL model.WebsiteSSL, req request.We
|
|||||||
config := nginxFull.SiteConfig.Config
|
config := nginxFull.SiteConfig.Config
|
||||||
server := config.FindServers()[0]
|
server := config.FindServers()[0]
|
||||||
server.UpdateListen("443", website.DefaultServer, "ssl")
|
server.UpdateListen("443", website.DefaultServer, "ssl")
|
||||||
|
if website.IPV6 {
|
||||||
|
server.UpdateListen("[::]:443", website.DefaultServer, "ssl")
|
||||||
|
}
|
||||||
|
|
||||||
switch req.HttpConfig {
|
switch req.HttpConfig {
|
||||||
case constant.HTTPSOnly:
|
case constant.HTTPSOnly:
|
||||||
@ -380,10 +392,16 @@ func applySSL(website model.Website, websiteSSL model.WebsiteSSL, req request.We
|
|||||||
server.RemoveDirective("if", []string{"($scheme"})
|
server.RemoveDirective("if", []string{"($scheme"})
|
||||||
case constant.HTTPToHTTPS:
|
case constant.HTTPToHTTPS:
|
||||||
server.UpdateListen("80", website.DefaultServer)
|
server.UpdateListen("80", website.DefaultServer)
|
||||||
|
if website.IPV6 {
|
||||||
|
server.UpdateListen("[::]:80", website.DefaultServer)
|
||||||
|
}
|
||||||
server.AddHTTP2HTTPS()
|
server.AddHTTP2HTTPS()
|
||||||
case constant.HTTPAlso:
|
case constant.HTTPAlso:
|
||||||
server.UpdateListen("80", website.DefaultServer)
|
server.UpdateListen("80", website.DefaultServer)
|
||||||
server.RemoveDirective("if", []string{"($scheme"})
|
server.RemoveDirective("if", []string{"($scheme"})
|
||||||
|
if website.IPV6 {
|
||||||
|
server.UpdateListen("[::]:80", website.DefaultServer)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := nginx.WriteConfig(config, nginx.IndentedStyle); err != nil {
|
if err := nginx.WriteConfig(config, nginx.IndentedStyle); err != nil {
|
||||||
|
@ -30,6 +30,7 @@ func Init() {
|
|||||||
migrations.UpdateTableAppDetail,
|
migrations.UpdateTableAppDetail,
|
||||||
migrations.AddBindAndAllowIPs,
|
migrations.AddBindAndAllowIPs,
|
||||||
migrations.UpdateCronjobWithSecond,
|
migrations.UpdateCronjobWithSecond,
|
||||||
|
migrations.UpdateWebsite,
|
||||||
})
|
})
|
||||||
if err := m.Migrate(); err != nil {
|
if err := m.Migrate(); err != nil {
|
||||||
global.LOG.Error(err)
|
global.LOG.Error(err)
|
||||||
|
@ -367,3 +367,13 @@ var UpdateCronjobWithSecond = &gormigrate.Migration{
|
|||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var UpdateWebsite = &gormigrate.Migration{
|
||||||
|
ID: "20200530-update-table-website",
|
||||||
|
Migrate: func(tx *gorm.DB) error {
|
||||||
|
if err := tx.AutoMigrate(&model.Website{}); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
},
|
||||||
|
}
|
||||||
|
@ -20,6 +20,7 @@ export namespace Website {
|
|||||||
rewrite: string;
|
rewrite: string;
|
||||||
user: string;
|
user: string;
|
||||||
group: string;
|
group: string;
|
||||||
|
IPV6: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface WebsiteDTO extends Website {
|
export interface WebsiteDTO extends Website {
|
||||||
@ -67,6 +68,7 @@ export namespace Website {
|
|||||||
remark: string;
|
remark: string;
|
||||||
webSiteGroupId: number;
|
webSiteGroupId: number;
|
||||||
expireDate?: string;
|
expireDate?: string;
|
||||||
|
IPV6: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface WebSiteOp {
|
export interface WebSiteOp {
|
||||||
|
@ -1391,6 +1391,7 @@ const message = {
|
|||||||
disable: 'not enabled',
|
disable: 'not enabled',
|
||||||
disableLeechHelper: 'Whether to disable the anti-leech',
|
disableLeechHelper: 'Whether to disable the anti-leech',
|
||||||
disableLeech: 'Disable anti-leech',
|
disableLeech: 'Disable anti-leech',
|
||||||
|
ipv6: 'Listen IPV6',
|
||||||
},
|
},
|
||||||
php: {
|
php: {
|
||||||
short_open_tag: 'Short tag support',
|
short_open_tag: 'Short tag support',
|
||||||
|
@ -1370,6 +1370,7 @@ const message = {
|
|||||||
disable: '未启用',
|
disable: '未启用',
|
||||||
disableLeechHelper: '是否禁用防盗链',
|
disableLeechHelper: '是否禁用防盗链',
|
||||||
disableLeech: '禁用防盗链',
|
disableLeech: '禁用防盗链',
|
||||||
|
ipv6: '监听 IPV6 端口',
|
||||||
},
|
},
|
||||||
php: {
|
php: {
|
||||||
short_open_tag: '短标签支持',
|
short_open_tag: '短标签支持',
|
||||||
|
@ -166,3 +166,14 @@ onMounted(() => {
|
|||||||
getWebsites();
|
getWebsites();
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.tag-button {
|
||||||
|
&.el-button--primary:hover {
|
||||||
|
background-color: var(--el-color-primary) !important;
|
||||||
|
}
|
||||||
|
&.el-button--primary:focus {
|
||||||
|
background-color: var(--el-color-primary) !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<el-row :gutter="20" v-loading="loading">
|
<el-row :gutter="20" v-loading="loading">
|
||||||
<el-col :xs="24" :sm="18" :md="14" :lg="14" :xl="14">
|
<el-col :xs="24" :sm="18" :md="14" :lg="14" :xl="14">
|
||||||
<el-form ref="httpsForm" label-position="left" label-width="auto" :model="form" :rules="rules">
|
<el-form ref="httpsForm" label-position="right" label-width="auto" :model="form" :rules="rules">
|
||||||
<el-form-item prop="enable" :label="$t('website.enableHTTPS')">
|
<el-form-item prop="enable" :label="$t('website.enableHTTPS')">
|
||||||
<el-switch v-model="form.enable" @change="changeEnable"></el-switch>
|
<el-switch v-model="form.enable" @change="changeEnable"></el-switch>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
<template>
|
<template>
|
||||||
<el-row :gutter="20" v-loading="loading">
|
<el-row :gutter="20" v-loading="loading">
|
||||||
<el-col :xs="24" :sm="18" :md="8" :lg="8" :xl="8">
|
<el-col :xs="24" :sm="18" :md="8" :lg="8" :xl="8">
|
||||||
<el-form-item prop="enable" :label="$t('website.enableOrNot')">
|
<el-form ref="limitForm" label-position="right" :model="form" :rules="rules" label-width="100px">
|
||||||
<el-switch v-model="enable" @change="changeEnable"></el-switch>
|
<el-form-item prop="enable" :label="$t('website.enableOrNot')">
|
||||||
</el-form-item>
|
<el-switch v-model="enable" @change="changeEnable"></el-switch>
|
||||||
<el-form ref="limitForm" label-position="left" :model="form" :rules="rules" label-width="100px">
|
</el-form-item>
|
||||||
<el-form-item :label="$t('website.limit')">
|
<el-form-item :label="$t('website.limit')">
|
||||||
<el-select v-model="ruleKey" @change="changeRule(ruleKey)">
|
<el-select v-model="ruleKey" @change="changeRule(ruleKey)">
|
||||||
<el-option :label="$t('website.current')" :value="'current'"></el-option>
|
<el-option :label="$t('website.current')" :value="'current'"></el-option>
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<el-row :gutter="20" v-loading="loading">
|
<el-row :gutter="20" v-loading="loading">
|
||||||
<el-col :xs="24" :sm="18" :md="8" :lg="8" :xl="8">
|
<el-col :xs="24" :sm="18" :md="8" :lg="8" :xl="8">
|
||||||
<el-form ref="websiteForm" label-position="left" label-width="80px" :model="form" :rules="rules">
|
<el-form ref="websiteForm" label-position="right" label-width="80px" :model="form" :rules="rules">
|
||||||
<el-form-item :label="$t('website.primaryDomain')" prop="primaryDomain">
|
<el-form-item :label="$t('website.primaryDomain')" prop="primaryDomain">
|
||||||
<el-input v-model="form.primaryDomain" disabled></el-input>
|
<el-input v-model="form.primaryDomain" disabled></el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
@ -18,6 +18,9 @@
|
|||||||
<el-form-item :label="$t('website.remark')" prop="remark">
|
<el-form-item :label="$t('website.remark')" prop="remark">
|
||||||
<el-input v-model="form.remark"></el-input>
|
<el-input v-model="form.remark"></el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
<el-form-item prop="IPV6">
|
||||||
|
<el-checkbox v-model="form.IPV6" :label="$t('website.ipv6')" size="large" />
|
||||||
|
</el-form-item>
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
<el-button type="primary" @click="submit(websiteForm)" :disabled="loading">
|
<el-button type="primary" @click="submit(websiteForm)" :disabled="loading">
|
||||||
{{ $t('commons.button.save') }}
|
{{ $t('commons.button.save') }}
|
||||||
@ -48,18 +51,19 @@ const props = defineProps({
|
|||||||
const websiteId = computed(() => {
|
const websiteId = computed(() => {
|
||||||
return Number(props.id);
|
return Number(props.id);
|
||||||
});
|
});
|
||||||
let loading = ref(false);
|
const loading = ref(false);
|
||||||
let form = reactive({
|
const form = reactive({
|
||||||
id: websiteId.value,
|
id: websiteId.value,
|
||||||
primaryDomain: '',
|
primaryDomain: '',
|
||||||
remark: '',
|
remark: '',
|
||||||
webSiteGroupId: 0,
|
webSiteGroupId: 0,
|
||||||
|
IPV6: false,
|
||||||
});
|
});
|
||||||
let rules = ref({
|
const rules = ref({
|
||||||
primaryDomain: [Rules.requiredInput],
|
primaryDomain: [Rules.requiredInput],
|
||||||
webSiteGroupId: [Rules.requiredSelect],
|
webSiteGroupId: [Rules.requiredSelect],
|
||||||
});
|
});
|
||||||
let groups = ref<Group.GroupInfo[]>([]);
|
const groups = ref<Group.GroupInfo[]>([]);
|
||||||
|
|
||||||
const submit = async (formEl: FormInstance | undefined) => {
|
const submit = async (formEl: FormInstance | undefined) => {
|
||||||
if (!formEl) return;
|
if (!formEl) return;
|
||||||
@ -86,6 +90,7 @@ const search = async () => {
|
|||||||
form.primaryDomain = res.data.primaryDomain;
|
form.primaryDomain = res.data.primaryDomain;
|
||||||
form.remark = res.data.remark;
|
form.remark = res.data.remark;
|
||||||
form.webSiteGroupId = res.data.webSiteGroupId;
|
form.webSiteGroupId = res.data.webSiteGroupId;
|
||||||
|
form.IPV6 = res.data.IPV6;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -252,6 +252,9 @@
|
|||||||
:placeholder="$t('website.domainHelper')"
|
:placeholder="$t('website.domainHelper')"
|
||||||
></el-input>
|
></el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
<el-form-item prop="IPV6">
|
||||||
|
<el-checkbox v-model="website.IPV6" :label="$t('website.ipv6')" size="large" />
|
||||||
|
</el-form-item>
|
||||||
<el-form-item :label="$t('website.alias')" prop="alias">
|
<el-form-item :label="$t('website.alias')" prop="alias">
|
||||||
<el-input v-model.trim="website.alias" :placeholder="$t('website.aliasHelper')"></el-input>
|
<el-input v-model.trim="website.alias" :placeholder="$t('website.aliasHelper')"></el-input>
|
||||||
<div>
|
<div>
|
||||||
@ -338,6 +341,7 @@ const website = ref({
|
|||||||
containerName: '',
|
containerName: '',
|
||||||
allowPort: false,
|
allowPort: false,
|
||||||
},
|
},
|
||||||
|
IPV6: false,
|
||||||
proxyType: 'tcp',
|
proxyType: 'tcp',
|
||||||
port: 9000,
|
port: 9000,
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user