mirror of
https://github.com/TeaOSLab/EdgeNode.git
synced 2025-11-06 01:50:26 +08:00
自动跳转到HTTPS可以设置允许和排除的域名
This commit is contained in:
@@ -144,10 +144,11 @@ func (this *HTTPRequest) Do() {
|
|||||||
|
|
||||||
// 自动跳转到HTTPS
|
// 自动跳转到HTTPS
|
||||||
if this.IsHTTP && this.web.RedirectToHttps != nil && this.web.RedirectToHttps.IsOn {
|
if this.IsHTTP && this.web.RedirectToHttps != nil && this.web.RedirectToHttps.IsOn {
|
||||||
this.doRedirectToHTTPS(this.web.RedirectToHttps)
|
if this.doRedirectToHTTPS(this.web.RedirectToHttps) {
|
||||||
this.doEnd()
|
this.doEnd()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Gzip
|
// Gzip
|
||||||
if this.web.GzipRef != nil && this.web.GzipRef.IsOn && this.web.Gzip != nil && this.web.Gzip.IsOn && this.web.Gzip.Level > 0 {
|
if this.web.GzipRef != nil && this.web.GzipRef.IsOn && this.web.Gzip != nil && this.web.Gzip.IsOn && this.web.Gzip.Level > 0 {
|
||||||
|
|||||||
@@ -7,9 +7,14 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (this *HTTPRequest) doRedirectToHTTPS(redirectToHTTPSConfig *serverconfigs.HTTPRedirectToHTTPSConfig) {
|
func (this *HTTPRequest) doRedirectToHTTPS(redirectToHTTPSConfig *serverconfigs.HTTPRedirectToHTTPSConfig) (shouldBreak bool) {
|
||||||
host := this.RawReq.Host
|
host := this.RawReq.Host
|
||||||
|
|
||||||
|
// 检查域名是否匹配
|
||||||
|
if !redirectToHTTPSConfig.MatchDomain(host) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
if len(redirectToHTTPSConfig.Host) > 0 {
|
if len(redirectToHTTPSConfig.Host) > 0 {
|
||||||
if redirectToHTTPSConfig.Port > 0 && redirectToHTTPSConfig.Port != 443 {
|
if redirectToHTTPSConfig.Port > 0 && redirectToHTTPSConfig.Port != 443 {
|
||||||
host = redirectToHTTPSConfig.Host + ":" + strconv.Itoa(redirectToHTTPSConfig.Port)
|
host = redirectToHTTPSConfig.Host + ":" + strconv.Itoa(redirectToHTTPSConfig.Port)
|
||||||
@@ -38,4 +43,6 @@ func (this *HTTPRequest) doRedirectToHTTPS(redirectToHTTPSConfig *serverconfigs.
|
|||||||
|
|
||||||
newURL := "https://" + host + this.RawReq.RequestURI
|
newURL := "https://" + host + this.RawReq.RequestURI
|
||||||
http.Redirect(this.writer, this.RawReq, newURL, statusCode)
|
http.Redirect(this.writer, this.RawReq, newURL, statusCode)
|
||||||
|
|
||||||
|
return true
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user