add trusted proxy for parsing client IPs (#115)

This commit is contained in:
Tobi Smethurst 2021-07-26 16:15:36 +02:00 committed by GitHub
commit e2757ae676
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 339 additions and 13 deletions

View file

@ -122,6 +122,11 @@ func New(cfg *config.Config, db db.DB, logger *logrus.Logger) (Router, error) {
engine := gin.Default()
engine.MaxMultipartMemory = 8 << 20 // 8 MiB
// set up IP forwarding via x-forward-* headers.
if err := engine.SetTrustedProxies(cfg.TrustedProxies); err != nil {
return nil, err
}
// enable cors on the engine
if err := useCors(cfg, engine); err != nil {
return nil, err