Handler implements a highly configurable and production-ready reverse proxy. Upon proxying, this module sets the following placeholders (which can be used both within and after this handler; for example, in response headers): Placeholder | Description ------------|------------- `{http.reverse_prox
| 98 | // `{http.reverse_proxy.duration_ms}` | Same as 'duration', but in milliseconds. |
| 99 | // `{http.reverse_proxy.retries}` | The number of retries actually performed to communicate with an upstream. |
| 100 | type Handler struct { |
| 101 | // Configures the method of transport for the proxy. A transport |
| 102 | // is what performs the actual "round trip" to the backend. |
| 103 | // The default transport is plaintext HTTP. |
| 104 | TransportRaw json.RawMessage `json:"transport,omitempty" caddy:"namespace=http.reverse_proxy.transport inline_key=protocol"` |
| 105 | |
| 106 | // A circuit breaker may be used to relieve pressure on a backend |
| 107 | // that is beginning to exhibit symptoms of stress or latency. |
| 108 | // By default, there is no circuit breaker. |
| 109 | CBRaw json.RawMessage `json:"circuit_breaker,omitempty" caddy:"namespace=http.reverse_proxy.circuit_breakers inline_key=type"` |
| 110 | |
| 111 | // Load balancing distributes load/requests between backends. |
| 112 | LoadBalancing *LoadBalancing `json:"load_balancing,omitempty"` |
| 113 | |
| 114 | // Health checks update the status of backends, whether they are |
| 115 | // up or down. Down backends will not be proxied to. |
| 116 | HealthChecks *HealthChecks `json:"health_checks,omitempty"` |
| 117 | |
| 118 | // Upstreams is the static list of backends to proxy to. |
| 119 | Upstreams UpstreamPool `json:"upstreams,omitempty"` |
| 120 | |
| 121 | // A module for retrieving the list of upstreams dynamically. Dynamic |
| 122 | // upstreams are retrieved at every iteration of the proxy loop for |
| 123 | // each request (i.e. before every proxy attempt within every request). |
| 124 | // Active health checks do not work on dynamic upstreams, and passive |
| 125 | // health checks are only effective on dynamic upstreams if the proxy |
| 126 | // server is busy enough that concurrent requests to the same backends |
| 127 | // are continuous. Instead of health checks for dynamic upstreams, it |
| 128 | // is recommended that the dynamic upstream module only return available |
| 129 | // backends in the first place. |
| 130 | DynamicUpstreamsRaw json.RawMessage `json:"dynamic_upstreams,omitempty" caddy:"namespace=http.reverse_proxy.upstreams inline_key=source"` |
| 131 | |
| 132 | // Adjusts how often to flush the response buffer. By default, |
| 133 | // no periodic flushing is done. A negative value disables |
| 134 | // response buffering, and flushes immediately after each |
| 135 | // write to the client. This option is ignored when the upstream's |
| 136 | // response is recognized as a streaming response, or if its |
| 137 | // content length is -1; for such responses, writes are flushed |
| 138 | // to the client immediately. |
| 139 | FlushInterval caddy.Duration `json:"flush_interval,omitempty"` |
| 140 | |
| 141 | // A list of IP ranges (supports CIDR notation) from which |
| 142 | // X-Forwarded-* header values should be trusted. By default, |
| 143 | // no proxies are trusted, so existing values will be ignored |
| 144 | // when setting these headers. If the proxy is trusted, then |
| 145 | // existing values will be used when constructing the final |
| 146 | // header values. |
| 147 | TrustedProxies []string `json:"trusted_proxies,omitempty"` |
| 148 | |
| 149 | // Headers manipulates headers between Caddy and the backend. |
| 150 | // By default, all headers are passed-thru without changes, |
| 151 | // with the exceptions of special hop-by-hop headers. |
| 152 | // |
| 153 | // X-Forwarded-For, X-Forwarded-Proto and X-Forwarded-Host |
| 154 | // are also set implicitly. |
| 155 | Headers *headers.Handler `json:"headers,omitempty"` |
| 156 | |
| 157 | // If nonzero, the entire request body up to this size will be read |
nothing calls this directly
no outgoing calls
no test coverage detected