github.com/nginxinc/kubernetes-ingress@v1.12.5/internal/configs/version1/config.go (about) 1 package version1 2 3 // UpstreamLabels describes the Prometheus labels for an NGINX upstream. 4 type UpstreamLabels struct { 5 Service string 6 ResourceType string 7 ResourceName string 8 ResourceNamespace string 9 } 10 11 // IngressNginxConfig describes an NGINX configuration. 12 type IngressNginxConfig struct { 13 Upstreams []Upstream 14 Servers []Server 15 Keepalive string 16 Ingress Ingress 17 SpiffeClientCerts bool 18 } 19 20 // Ingress holds information about an Ingress resource. 21 type Ingress struct { 22 Name string 23 Namespace string 24 Annotations map[string]string 25 } 26 27 // Upstream describes an NGINX upstream. 28 type Upstream struct { 29 Name string 30 UpstreamServers []UpstreamServer 31 StickyCookie string 32 LBMethod string 33 Queue int64 34 QueueTimeout int64 35 UpstreamZoneSize string 36 UpstreamLabels UpstreamLabels 37 } 38 39 // UpstreamServer describes a server in an NGINX upstream. 40 type UpstreamServer struct { 41 Address string 42 Port string 43 MaxFails int 44 MaxConns int 45 FailTimeout string 46 SlowStart string 47 Resolve bool 48 } 49 50 // HealthCheck describes an active HTTP health check. 51 type HealthCheck struct { 52 UpstreamName string 53 URI string 54 Interval int32 55 Fails int32 56 Passes int32 57 Scheme string 58 Mandatory bool 59 Headers map[string]string 60 TimeoutSeconds int64 61 } 62 63 // Server describes an NGINX server. 64 type Server struct { 65 ServerSnippets []string 66 Name string 67 ServerTokens string 68 Locations []Location 69 SSL bool 70 SSLCertificate string 71 SSLCertificateKey string 72 SSLRejectHandshake bool 73 TLSPassthrough bool 74 GRPCOnly bool 75 StatusZone string 76 HTTP2 bool 77 RedirectToHTTPS bool 78 SSLRedirect bool 79 ProxyProtocol bool 80 HSTS bool 81 HSTSMaxAge int64 82 HSTSIncludeSubdomains bool 83 HSTSBehindProxy bool 84 ProxyHideHeaders []string 85 ProxyPassHeaders []string 86 87 HealthChecks map[string]HealthCheck 88 89 RealIPHeader string 90 SetRealIPFrom []string 91 RealIPRecursive bool 92 93 JWTAuth *JWTAuth 94 JWTRedirectLocations []JWTRedirectLocation 95 96 Ports []int 97 SSLPorts []int 98 AppProtectEnable string 99 AppProtectPolicy string 100 AppProtectLogConfs []string 101 AppProtectLogEnable string 102 103 SpiffeCerts bool 104 } 105 106 // JWTRedirectLocation describes a location for redirecting client requests to a login URL for JWT Authentication. 107 type JWTRedirectLocation struct { 108 Name string 109 LoginURL string 110 } 111 112 // JWTAuth holds JWT authentication configuration. 113 type JWTAuth struct { 114 Key string 115 Realm string 116 Token string 117 RedirectLocationName string 118 } 119 120 // Location describes an NGINX location. 121 type Location struct { 122 LocationSnippets []string 123 Path string 124 Upstream Upstream 125 ProxyConnectTimeout string 126 ProxyReadTimeout string 127 ProxySendTimeout string 128 ClientMaxBodySize string 129 Websocket bool 130 Rewrite string 131 SSL bool 132 GRPC bool 133 ProxyBuffering bool 134 ProxyBuffers string 135 ProxyBufferSize string 136 ProxyMaxTempFileSize string 137 ProxySSLName string 138 JWTAuth *JWTAuth 139 ServiceName string 140 141 MinionIngress *Ingress 142 } 143 144 // MainConfig describe the main NGINX configuration file. 145 type MainConfig struct { 146 AccessLogOff bool 147 DefaultServerAccessLogOff bool 148 DefaultServerReturn string 149 ErrorLogLevel string 150 HealthStatus bool 151 HealthStatusURI string 152 HTTP2 bool 153 HTTPSnippets []string 154 KeepaliveRequests int64 155 KeepaliveTimeout string 156 LogFormat []string 157 LogFormatEscaping string 158 MainSnippets []string 159 NginxStatus bool 160 NginxStatusAllowCIDRs []string 161 NginxStatusPort int 162 OpenTracingEnabled bool 163 OpenTracingLoadModule bool 164 OpenTracingTracer string 165 OpenTracingTracerConfig string 166 ProxyProtocol bool 167 ResolverAddresses []string 168 ResolverIPV6 bool 169 ResolverTimeout string 170 ResolverValid string 171 RealIPHeader string 172 RealIPRecursive bool 173 SetRealIPFrom []string 174 ServerNamesHashBucketSize string 175 ServerNamesHashMaxSize string 176 ServerTokens string 177 SSLRejectHandshake bool 178 SSLCiphers string 179 SSLDHParam string 180 SSLPreferServerCiphers bool 181 SSLProtocols string 182 StreamLogFormat []string 183 StreamLogFormatEscaping string 184 StreamSnippets []string 185 StubStatusOverUnixSocketForOSS bool 186 TLSPassthrough bool 187 VariablesHashBucketSize uint64 188 VariablesHashMaxSize uint64 189 WorkerConnections string 190 WorkerCPUAffinity string 191 WorkerProcesses string 192 WorkerRlimitNofile string 193 WorkerShutdownTimeout string 194 AppProtectLoadModule bool 195 AppProtectFailureModeAction string 196 AppProtectCookieSeed string 197 AppProtectCPUThresholds string 198 AppProtectPhysicalMemoryThresholds string 199 InternalRouteServer bool 200 InternalRouteServerName string 201 LatencyMetrics bool 202 PreviewPolicies bool 203 } 204 205 // NewUpstreamWithDefaultServer creates an upstream with the default server. 206 // proxy_pass to an upstream with the default server returns 502. 207 // We use it for services that have no endpoints. 208 func NewUpstreamWithDefaultServer(name string) Upstream { 209 return Upstream{ 210 Name: name, 211 UpstreamZoneSize: "256k", 212 UpstreamServers: []UpstreamServer{ 213 { 214 Address: "127.0.0.1", 215 Port: "8181", 216 MaxFails: 1, 217 MaxConns: 0, 218 FailTimeout: "10s", 219 }, 220 }, 221 } 222 }