Skip to content
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

Add status endpoint #333

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions model/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ type RouterConfig struct {
HTTP2Enabled bool `key:"http2Enabled" constraint:"(?i)^(true|false)$"`
LogFormat string `key:"logFormat"`
ProxyBuffersConfig *ProxyBuffersConfig `key:"proxyBuffers"`
StatusEndpoint bool `key:"statusEndpoint" constraint:"(?i)^(true|false)$"`
}

func newRouterConfig() (*RouterConfig, error) {
Expand Down Expand Up @@ -95,6 +96,7 @@ func newRouterConfig() (*RouterConfig, error) {
HTTP2Enabled: true,
LogFormat: `[$time_iso8601] - $app_name - $remote_addr - $remote_user - $status - "$request" - $bytes_sent - "$http_referer" - "$http_user_agent" - "$server_name" - $upstream_addr - $http_host - $upstream_response_time - $request_time`,
ProxyBuffersConfig: proxyBuffersConfig,
StatusEndpoint: false,
}, nil
}

Expand Down
15 changes: 14 additions & 1 deletion nginx/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,13 @@ http {
default_type 'text/plain';
return 200;
}

{{ if $routerConfig.statusEndpoint }}
location /nginx_status {
stub_status on;
allow 127.0.0.1;
deny all;
}
{{ end }}
location / {
proxy_buffering {{ if $routerConfig.ProxyBuffersConfig.Enabled }}on{{ else }}off{{ end }};
proxy_buffer_size {{ $routerConfig.ProxyBuffersConfig.Size }};
Expand Down Expand Up @@ -186,6 +192,13 @@ http {
location / {
return 404;
}
{{ if $routerConfig.statusEndpoint }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see you groomed the commits and force-pushed... I think you lost the model changes that complement this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Damn indeed. :) That's stupid.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would consider moving this section up between the health check and the location / block. I know Nginx works by making the best/closest match, but for human readability, it usually makes the most sense to have the more specific patterns listed first so that you can think of unmatched requests as progressively "falling through" the list for a possible match to a more general pattern... if you don't mind.

location /nginx_status {
stub_status on;
allow 127.0.0.1;
deny all;
}
{{ end }}
}
{{ end }}

Expand Down