mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2025-04-19 21:42:24 +00:00
Fix domain validation for Nginx/CDN compatibility #2450
This commit is contained in:
parent
7b8ef98846
commit
604b9be4a0
1 changed files with 3 additions and 9 deletions
|
@ -10,15 +10,9 @@ import (
|
||||||
|
|
||||||
func DomainValidatorMiddleware(domain string) gin.HandlerFunc {
|
func DomainValidatorMiddleware(domain string) gin.HandlerFunc {
|
||||||
return func(c *gin.Context) {
|
return func(c *gin.Context) {
|
||||||
host := c.GetHeader("X-Forwarded-Host")
|
host := c.Request.Host
|
||||||
if host == "" {
|
if colonIndex := strings.LastIndex(host, ":"); colonIndex != -1 {
|
||||||
host = c.GetHeader("X-Real-IP")
|
host, _, _ = net.SplitHostPort(c.Request.Host)
|
||||||
}
|
|
||||||
if host == "" {
|
|
||||||
host = c.Request.Host
|
|
||||||
if colonIndex := strings.LastIndex(host, ":"); colonIndex != -1 {
|
|
||||||
host, _, _ = net.SplitHostPort(host)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if host != domain {
|
if host != domain {
|
||||||
|
|
Loading…
Reference in a new issue