Skip to content
Snippets Groups Projects
Unverified Commit 072e5246 authored by Alexander Olofsson's avatar Alexander Olofsson
Browse files

Add config flag to ignore XFH header

Fixes #202
parent 771e3fbd
No related branches found
No related tags found
No related merge requests found
...@@ -31,7 +31,7 @@ type handler struct { ...@@ -31,7 +31,7 @@ type handler struct {
func (h handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { func (h handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
isUsingForwardedHost := false isUsingForwardedHost := false
if r.Header.Get("X-Forwarded-Host") != "" { if r.Header.Get("X-Forwarded-Host") != "" && !config.Get().General.IgnoreForwardedHost {
r.Host = r.Header.Get("X-Forwarded-Host") r.Host = r.Header.Get("X-Forwarded-Host")
isUsingForwardedHost = true isUsingForwardedHost = true
} }
......
...@@ -23,10 +23,11 @@ type HomeserverConfig struct { ...@@ -23,10 +23,11 @@ type HomeserverConfig struct {
} }
type GeneralConfig struct { type GeneralConfig struct {
BindAddress string `yaml:"bindAddress"` BindAddress string `yaml:"bindAddress"`
Port int `yaml:"port"` Port int `yaml:"port"`
LogDirectory string `yaml:"logDirectory"` LogDirectory string `yaml:"logDirectory"`
TrustAnyForward bool `yaml:"trustAnyForwardedAddress"` TrustAnyForward bool `yaml:"trustAnyForwardedAddress"`
IgnoreForwardedHost bool `yaml:"ignoreForwardedHost"`
} }
type DbPoolConfig struct { type DbPoolConfig struct {
...@@ -219,10 +220,11 @@ func Get() *MediaRepoConfig { ...@@ -219,10 +220,11 @@ func Get() *MediaRepoConfig {
func NewDefaultConfig() *MediaRepoConfig { func NewDefaultConfig() *MediaRepoConfig {
return &MediaRepoConfig{ return &MediaRepoConfig{
General: &GeneralConfig{ General: &GeneralConfig{
BindAddress: "127.0.0.1", BindAddress: "127.0.0.1",
Port: 8000, Port: 8000,
LogDirectory: "logs", LogDirectory: "logs",
TrustAnyForward: false, TrustAnyForward: false,
IgnoreForwardedHost: false,
}, },
Database: &DatabaseConfig{ Database: &DatabaseConfig{
Postgres: "postgres://your_username:your_password@localhost/database_name?sslmode=disable", Postgres: "postgres://your_username:your_password@localhost/database_name?sslmode=disable",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment