\fIproxy\fR\- facilitates both a basic reverse proxy and a robust load balancer\.
.
.SH"DESCRIPTION"
The proxy has support for multiple backends\. The load balancing features include multiple policies, health checks, and failovers\. If all hosts fail their health check the proxy plugin will fail back to randomly selecting a target and sending packets to it\.
.
.SH"SYNTAX"
In its most basic form, a simple reverse proxy uses this syntax:
.
.IP""4
.
.nf
proxy FROM TO
.
.fi
.
.IP""0
.
.IP"\(bu"4
\fBFROM\fR is the base domain to match for the request to be proxied\.
.
.IP"\(bu"4
\fBTO\fR is the destination endpoint to proxy to\.
.
.IP""0
.
.P
However, advanced features including load balancing can be utilized with an expanded syntax:
\fBFROM\fR is the name to match for the request to be proxied\.
.
.IP"\(bu"4
\fBTO\fR is the destination endpoint to proxy to\. At least one is required, but multiple may be specified\.\fBTO\fR may be an IP:Port pair, or may reference a file in resolv\.conf format
\fBpolicy\fR is the load balancing policy to use; applies only with multiple backends\. May be one of random, least_conn, round_robin or sequential\. Default is random\.
\fBfail_timeout\fR specifies how long to consider a backend as down after it has failed\. While it is down, requests will not be routed to that backend\. A backend is "down" if CoreDNS fails to communicate with it\. The default value is 2 seconds ("2s")\.
.
.IP"\(bu"4
\fBmax_fails\fR is the number of failures within fail_timeout that are needed before considering a backend to be down\. If 0, the backend will never be marked as down\. Default is 1\.
.
.IP"\(bu"4
\fBhealth_check\fR will check \fBPATH\fR (on \fBPORT\fR) on each backend\. If a backend returns a status code of 200\-399, then that backend is marked healthy for double the healthcheck duration\. If it doesn\'t, it is marked as unhealthy and no requests are routed to it\. If this option is not provided then health checks are disabled\. The default duration is 4 seconds ("4s")\.
.
.IP"\(bu"4
\fBIGNORED_NAMES\fR in \fBexcept\fR is a space\-separated list of domains to exclude from proxying\. Requests that match none of these names will be passed through\.
.
.IP"\(bu"4
\fBspray\fR when all backends are unhealthy, randomly pick one to send the traffic to\. (This is a failsafe\.)
\fBprotocol\fR specifies what protocol to use to speak to an upstream, \fBdns\fR (the default) is plain old DNS\. The \fBgrpc\fR option will talk to a server that has implemented the DnsService \fIhttps://github\.com/coredns/coredns/blob/master/pb/dns\.proto\fR\.
All polices implement randomly spraying packets to backend hosts when \fIno healthy\fR hosts are available\. This is to preempt the case where the healthchecking (as a mechanism) fails\.
uses the standard DNS exchange\. You can pass \fBforce_tcp\fR to make sure that the proxied connection is performed over TCP, regardless of the inbound request\'s protocol\.
.
.TP
\fBgrpc\fR
extra options are used to control how the TLS connection is made to the gRPC server\.
.
.IP"\(bu"4
None \- No client authentication is used, and the system CAs are used to verify the server certificate\.
.
.IP"\(bu"4
\fBinsecure\fR\- TLS is not used, the connection is made in plaintext (not good in production)\.
.
.IP"\(bu"4
\fBCACERT\fR\- No client authentication is used, and the file \fBCACERT\fR is used to verify the server certificate\.
.
.IP"\(bu"4
\fBKEY\fR\fBCERT\fR\- Client authentication is used with the specified key/cert pair\. The server certificate is verified with the system CAs\.
\fBKEY\fR\fBCERT\fR\fBCACERT\fR\- Client authentication is used with the specified key/cert pair\. The server certificate is verified using the \fBCACERT\fR file\.
Where \fBproxy_proto\fR is the protocol used (\fBdns\fR or \fBgrpc\fR) and \fBto\fR is \fBTO\fR specified in the config, \fBproto\fR is the protocol used by the incoming query ("tcp" or "udp"), family the transport family ("1" for IPv4, and "2" for IPv6)\.\fBServer\fR is the server responsible for the request (and metric)\. See the documentation in the metrics plugin\.