1# [Chi](https://github.com/go-chi/chi) proxy middleware 2 3Forwarded headers middleware to use if application is run behind reverse proxy. 4 5[![Documentation](https://godoc.org/github.com/chi-middleware/proxy?status.svg)](https://pkg.go.dev/github.com/chi-middleware/proxy) 6[![codecov](https://codecov.io/gh/chi-middleware/proxy/branch/master/graph/badge.svg)](https://codecov.io/gh/chi-middleware/proxy) 7[![Go Report Card](https://goreportcard.com/badge/github.com/chi-middleware/proxy)](https://goreportcard.com/report/github.com/chi-middleware/proxy) 8[![Build Status](https://cloud.drone.io/api/badges/chi-middleware/proxy/status.svg?ref=refs/heads/master)](https://cloud.drone.io/chi-middleware/proxy) 9 10## Usage 11 12Import using: 13 14```go 15import "github.com/chi-middleware/proxy" 16``` 17 18Use middleware with default options (trusted from proxy `127.0.0.1` and trusts only last IP address provided in header): 19 20```go 21 r := chi.NewRouter() 22 r.Use(proxy.ForwardedHeaders()) 23``` 24 25Extend default options: 26 27```go 28 r := chi.NewRouter() 29 r.Use(proxy.ForwardedHeaders( 30 proxy.NewForwardedHeadersOptions(). 31 WithForwardLimit(2). 32 ClearTrustedProxies().AddTrustedProxy("10.0.0.1"), 33 )) 34``` 35 36Provide custom options: 37 38```go 39 r := chi.NewRouter() 40 r.Use(proxy.ForwardedHeaders(&ForwardedHeadersOptions{ 41 ForwardLimit: 1, 42 TrustedProxies: []net.IP{ 43 net.IPv4(10, 0, 0, 1), 44 }, 45 })) 46``` 47