-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cleanup #373
Cleanup #373
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,11 +17,11 @@ limitations under the License. | |
package config | ||
|
||
import ( | ||
"fmt" | ||
"runtime" | ||
|
||
"github.com/golang/glog" | ||
|
||
"fmt" | ||
"k8s.io/ingress/core/pkg/ingress" | ||
"k8s.io/ingress/core/pkg/ingress/defaults" | ||
) | ||
|
@@ -47,9 +47,9 @@ const ( | |
|
||
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" | ||
|
||
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'" | ||
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"` | ||
|
||
logFormatStream = "'$remote_addr [$time_local] $protocol [$ssl_preread_server_name] [$stream_upstream] $status $bytes_sent $bytes_received $session_time'" | ||
logFormatStream = `[$time_local] $protocol [$ssl_preread_server_name] [$stream_upstream] $status $bytes_sent $bytes_received $session_time` | ||
|
||
// http://nginx.org/en/docs/http/ngx_http_ssl_module.html#ssl_buffer_size | ||
// Sets the size of the buffer used for sending data. | ||
|
@@ -97,11 +97,6 @@ type Configuration struct { | |
//http://nginx.org/en/docs/http/ngx_http_log_module.html | ||
DisableAccessLog bool `json:"disable-access-log,omitempty"` | ||
|
||
// EnableSPDY enables spdy and use ALPN and NPN to advertise the availability of the two protocols | ||
// https://blog.cloudflare.com/open-sourcing-our-nginx-http-2-spdy-code | ||
// By default this is enabled | ||
EnableSPDY bool `json:"enable-spdy"` | ||
|
||
// EnableStickySessions enabled sticky sessions using cookies | ||
// https://bitbucket.org/nginx-goodies/nginx-sticky-module-ng | ||
// By default this is disabled | ||
|
@@ -255,7 +250,6 @@ func NewDefault() Configuration { | |
ClientHeaderBufferSize: "1k", | ||
DisableAccessLog: false, | ||
EnableDynamicTLSRecords: true, | ||
EnableSPDY: false, | ||
ErrorLogLevel: errorLevel, | ||
HSTS: true, | ||
HSTSIncludeSubdomains: true, | ||
|
@@ -264,7 +258,7 @@ func NewDefault() Configuration { | |
KeepAlive: 75, | ||
LargeClientHeaderBuffers: "4 8k", | ||
LogFormatStream: logFormatStream, | ||
LogFormatUpstream: BuildLogFormatUpstream(false, ""), | ||
LogFormatUpstream: logFormatUpstream, | ||
MaxWorkerConnections: 16384, | ||
MapHashBucketSize: 64, | ||
ProxyRealIPCIDR: defIPCIDR, | ||
|
@@ -307,20 +301,14 @@ func NewDefault() Configuration { | |
return cfg | ||
} | ||
|
||
// BuildLogFormatUpstream format the log_format upstream based on proxy_protocol | ||
func BuildLogFormatUpstream(useProxyProtocol bool, curLogFormatUpstream string) string { | ||
|
||
// test if log_format comes from configmap | ||
if curLogFormatUpstream != "" && | ||
curLogFormatUpstream != fmt.Sprintf(logFormatUpstream, "$proxy_protocol_addr") && | ||
curLogFormatUpstream != fmt.Sprintf(logFormatUpstream, "$remote_addr") { | ||
return curLogFormatUpstream | ||
} | ||
|
||
if useProxyProtocol { | ||
return fmt.Sprintf(logFormatUpstream, "$proxy_protocol_addr") | ||
// BuildLogFormatUpstream format the log_format upstream using | ||
// proxy_protocol_addr as remote client address if UseProxyProtocol | ||
// is enabled. | ||
func (cfg Configuration) BuildLogFormatUpstream() string { | ||
if cfg.UseProxyProtocol { | ||
return fmt.Sprintf("$proxy_protocol_addr - %s", cfg.LogFormatUpstream) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is breaking overrides of the log format and just seems extremely sloppy as users are now stuck with a hardcoded string format ( Please revert or fix this as i (and i figure lots of people) want to define my own structured logging format and this IP prefix is preventing this. |
||
} | ||
return fmt.Sprintf(logFormatUpstream, "$remote_addr") | ||
return fmt.Sprintf("$remote_addr - %s", cfg.LogFormatUpstream) | ||
} | ||
|
||
// TemplateConfig contains the nginx configuration to render the file nginx.conf | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aledbf Don't forget to compare if the logFormatUpstream is coming from configmap. (--log-format-upstream)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gianrubio no need. At this point the configuration contains the default value or the defined in the configmap.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean, if I have this configmap
and change to this?
ingress will build a wrong log_format