@@ -17,11 +17,11 @@ limitations under the License.
17
17
package config
18
18
19
19
import (
20
+ "fmt"
20
21
"runtime"
21
22
22
23
"github.com/golang/glog"
23
24
24
- "fmt"
25
25
"k8s.io/ingress/core/pkg/ingress"
26
26
"k8s.io/ingress/core/pkg/ingress/defaults"
27
27
)
@@ -47,9 +47,9 @@ const (
47
47
48
48
gzipTypes = "application/atom+xml application/javascript application/x-javascript application/json application/rss+xml application/vnd.ms-fontobject application/x-font-ttf application/x-web-app-manifest+json application/xhtml+xml application/xml font/opentype image/svg+xml image/x-icon text/css text/plain text/x-component"
49
49
50
- logFormatUpstream = "'%v - [$proxy_add_x_forwarded_for] - $remote_user [$time_local] \ " $request\ " $status $body_bytes_sent \ " $http_referer\" \ " $http_user_agent\ " $request_length $request_time [$proxy_upstream_name] $upstream_addr $upstream_response_length $upstream_response_time $upstream_status'"
50
+ logFormatUpstream = ` [$proxy_add_x_forwarded_for] - $remote_user [$time_local] "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent" $request_length $request_time [$proxy_upstream_name] $upstream_addr $upstream_response_length $upstream_response_time $upstream_status"`
51
51
52
- logFormatStream = "'$remote_addr [$time_local] $protocol [$ssl_preread_server_name] [$stream_upstream] $status $bytes_sent $bytes_received $session_time'"
52
+ logFormatStream = ` [$time_local] $protocol [$ssl_preread_server_name] [$stream_upstream] $status $bytes_sent $bytes_received $session_time`
53
53
54
54
// http://nginx.org/en/docs/http/ngx_http_ssl_module.html#ssl_buffer_size
55
55
// Sets the size of the buffer used for sending data.
@@ -97,11 +97,6 @@ type Configuration struct {
97
97
//http://nginx.org/en/docs/http/ngx_http_log_module.html
98
98
DisableAccessLog bool `json:"disable-access-log,omitempty"`
99
99
100
- // EnableSPDY enables spdy and use ALPN and NPN to advertise the availability of the two protocols
101
- // https://blog.cloudflare.com/open-sourcing-our-nginx-http-2-spdy-code
102
- // By default this is enabled
103
- EnableSPDY bool `json:"enable-spdy"`
104
-
105
100
// EnableStickySessions enabled sticky sessions using cookies
106
101
// https://bitbucket.org/nginx-goodies/nginx-sticky-module-ng
107
102
// By default this is disabled
@@ -255,7 +250,6 @@ func NewDefault() Configuration {
255
250
ClientHeaderBufferSize : "1k" ,
256
251
DisableAccessLog : false ,
257
252
EnableDynamicTLSRecords : true ,
258
- EnableSPDY : false ,
259
253
ErrorLogLevel : errorLevel ,
260
254
HSTS : true ,
261
255
HSTSIncludeSubdomains : true ,
@@ -264,7 +258,7 @@ func NewDefault() Configuration {
264
258
KeepAlive : 75 ,
265
259
LargeClientHeaderBuffers : "4 8k" ,
266
260
LogFormatStream : logFormatStream ,
267
- LogFormatUpstream : BuildLogFormatUpstream ( false , "" ) ,
261
+ LogFormatUpstream : logFormatUpstream ,
268
262
MaxWorkerConnections : 16384 ,
269
263
MapHashBucketSize : 64 ,
270
264
ProxyRealIPCIDR : defIPCIDR ,
@@ -307,20 +301,14 @@ func NewDefault() Configuration {
307
301
return cfg
308
302
}
309
303
310
- // BuildLogFormatUpstream format the log_format upstream based on proxy_protocol
311
- func BuildLogFormatUpstream (useProxyProtocol bool , curLogFormatUpstream string ) string {
312
-
313
- // test if log_format comes from configmap
314
- if curLogFormatUpstream != "" &&
315
- curLogFormatUpstream != fmt .Sprintf (logFormatUpstream , "$proxy_protocol_addr" ) &&
316
- curLogFormatUpstream != fmt .Sprintf (logFormatUpstream , "$remote_addr" ) {
317
- return curLogFormatUpstream
318
- }
319
-
320
- if useProxyProtocol {
321
- return fmt .Sprintf (logFormatUpstream , "$proxy_protocol_addr" )
304
+ // BuildLogFormatUpstream format the log_format upstream using
305
+ // proxy_protocol_addr as remote client address if UseProxyProtocol
306
+ // is enabled.
307
+ func (cfg Configuration ) BuildLogFormatUpstream () string {
308
+ if cfg .UseProxyProtocol {
309
+ return fmt .Sprintf ("$proxy_protocol_addr - %s" , cfg .LogFormatUpstream )
322
310
}
323
- return fmt .Sprintf (logFormatUpstream , "$remote_addr" )
311
+ return fmt .Sprintf ("$remote_addr - %s" , cfg . LogFormatUpstream )
324
312
}
325
313
326
314
// TemplateConfig contains the nginx configuration to render the file nginx.conf
0 commit comments