Files
1Panel/agent/app/dto/request/nginx.go
双向极端andBOX e66f808ed6 Feat/Add custom HTTPS redirect port option for websites (#14491)
* feat(website): add custom HTTPS redirect port option

Allow HTTP-to-HTTPS redirects to omit the local HTTPS port for Cloudflare or other reverse-proxy deployments terminating at 443. Apply the setting to existing websites and update HTTPS settings labels.

(cherry picked from commit 27c1468405)

* feat(website): configure HTTPS redirect port per site

Add a per-site HTTPS redirect port policy next to the HTTP-to-HTTPS option. Sites can inherit the global setting, use the Nginx HTTPS port, or force standard port 443, defaulting existing sites to inheritance.

This supports reverse-proxied sites that need 443 and directly exposed sites that need 8443 on the same host. Global changes now update only inheriting sites, so adjusting one website does not rewrite other sites' redirect rules.

Hide the global custom-port switch when Nginx uses standard port 443.

(cherry picked from commit 301dc15d9d)

* Revert "feat(website): configure HTTPS redirect port per site"

This reverts commit 83d94f6cf9.

The per-site database strategy will be replaced by a config-driven design.

* feat(website): make HTTPS redirect port config-driven

Read the site redirect port from managed nginx rules instead of storing per-site policy in the database. Only update rules matching the old global port, preserve manual configurations, and avoid rewriting sites when the global redirect setting is unchanged.

---------

Co-authored-by: BOX <no@mail.com>
2026-11-26 14:14:28 +08:00

144 lines
4.8 KiB
Go

package request
import "github.com/1Panel-dev/1Panel/agent/app/dto"
type NginxConfigFileUpdate struct {
Content string `json:"content" validate:"required"`
Backup bool `json:"backup"`
}
type NginxScopeReq struct {
Scope dto.NginxKey `json:"scope" validate:"required"`
WebsiteID uint `json:"websiteId"`
}
type NginxConfigUpdate struct {
Scope dto.NginxKey `json:"scope"`
Operate string `json:"operate" validate:"required,oneof=add update delete"`
WebsiteID uint `json:"websiteId"`
Params interface{} `json:"params"`
}
type NginxRewriteReq struct {
WebsiteID uint `json:"websiteId" validate:"required"`
Name string `json:"name" validate:"required"`
}
type CustomRewriteOperate struct {
Operate string `json:"operate" validate:"required,oneof=create delete"`
Content string `json:"content"`
Name string `json:"name"`
}
type NginxRewriteUpdate struct {
WebsiteID uint `json:"websiteId" validate:"required"`
Name string `json:"name" validate:"required"`
Content string `json:"content"`
}
type NginxProxyUpdate struct {
WebsiteID uint `json:"websiteID" validate:"required"`
Content string `json:"content" validate:"required"`
Name string `json:"name" validate:"required"`
}
type NginxProxyCacheUpdate struct {
WebsiteID uint `json:"websiteID" validate:"required"`
Open bool `json:"open"`
CacheLimit int `json:"cacheLimit" validate:"required"`
CacheLimitUnit string `json:"cacheLimitUnit" validate:"required"`
ShareCache int `json:"shareCache" validate:"required"`
ShareCacheUnit string `json:"shareCacheUnit" validate:"required"`
CacheExpire int `json:"cacheExpire" validate:"required"`
CacheExpireUnit string `json:"cacheExpireUnit" validate:"required"`
}
type NginxAuthUpdate struct {
WebsiteID uint `json:"websiteID" validate:"required"`
Operate string `json:"operate" validate:"required"`
Username string `json:"username"`
Password string `json:"password"`
Remark string `json:"remark"`
}
type NginxPathAuthUpdate struct {
WebsiteID uint `json:"websiteID" validate:"required"`
Operate string `json:"operate" validate:"required"`
Name string `json:"name"`
Username string `json:"username"`
Password string `json:"password"`
Path string `json:"path"`
Remark string `json:"remark"`
}
type NginxAuthReq struct {
WebsiteID uint `json:"websiteID" validate:"required"`
}
type NginxCommonReq struct {
WebsiteID uint `json:"websiteID" validate:"required"`
}
type NginxAntiLeechUpdate struct {
WebsiteID uint `json:"websiteID" validate:"required"`
Extends string `json:"extends"`
Return string `json:"return"`
Enable bool `json:"enable" `
ServerNames []string `json:"serverNames"`
Cache bool `json:"cache"`
CacheTime int `json:"cacheTime"`
CacheUint string `json:"cacheUint"`
NoneRef bool `json:"noneRef"`
LogEnable bool `json:"logEnable"`
Blocked bool `json:"blocked"`
}
type NginxRedirectReq struct {
Name string `json:"name" validate:"required"`
WebsiteID uint `json:"websiteID" validate:"required"`
Domains []string `json:"domains"`
KeepPath bool `json:"keepPath"`
Enable bool `json:"enable"`
Type string `json:"type" validate:"required"`
Redirect string `json:"redirect" validate:"required"`
Path string `json:"path"`
Target string `json:"target" validate:"required"`
Operate string `json:"operate" validate:"required"`
RedirectRoot bool `json:"redirectRoot"`
}
type NginxRedirectUpdate struct {
WebsiteID uint `json:"websiteID" validate:"required"`
Content string `json:"content" validate:"required"`
Name string `json:"name" validate:"required"`
}
type NginxBuildReq struct {
TaskID string `json:"taskID" validate:"required"`
Mirror string `json:"mirror" validate:"required"`
Modules []string `json:"modules"`
Force bool `json:"force"`
}
type NginxModuleUpdate struct {
Operate string `json:"operate" validate:"required,oneof=create delete update"`
Name string `json:"name" validate:"required"`
Script string `json:"script"`
Packages string `json:"packages"`
Enable bool `json:"enable"`
Params string `json:"params"`
BuildMode string `json:"buildMode" validate:"omitempty,oneof=dynamic static"`
Provider string `json:"provider" validate:"omitempty,oneof=local prebuilt"`
LoadOrder int `json:"loadOrder" validate:"omitempty,min=0,max=9999"`
}
type NginxOperateReq struct {
Operate string `json:"operate" validate:"required,oneof=enable disable"`
}
type NginxDefaultHTTPSUpdate struct {
Operate string `json:"operate" validate:"required,oneof=enable disable"`
SSLRejectHandshake bool `json:"sslRejectHandshake"`
HTTPSRedirectCustomPort *bool `json:"httpsRedirectCustomPort"`
}