Add Ubuntu deployment: scripts, SSL, systemd and setup.sh
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
package middleware
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// TrustProxy восстанавливает схему HTTPS за Caddy/nginx.
|
||||
func TrustProxy(next http.Handler) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
if proto := r.Header.Get("X-Forwarded-Proto"); strings.EqualFold(proto, "https") {
|
||||
r.URL.Scheme = "https"
|
||||
}
|
||||
if host := r.Header.Get("X-Forwarded-Host"); host != "" {
|
||||
r.Host = host
|
||||
}
|
||||
next.ServeHTTP(w, r)
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user