-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #38 from whylabs/dev/aberg/gr-nginx-#00000001
Adding support for proxy cache
- Loading branch information
Showing
12 changed files
with
746 additions
and
266 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
{{- if .Values.cache.enable }} | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: {{ .Release.Name }}-nginx | ||
data: | ||
nginx.conf: | | ||
pid /tmp/nginx.pid; | ||
events { | ||
worker_connections 1024; | ||
} | ||
http { | ||
proxy_cache_path /tmp/nginx_cache levels=1:2 keys_zone=my_cache:10m max_size=1g | ||
inactive=60m use_temp_path=off; | ||
client_body_temp_path /tmp/client_temp; | ||
proxy_temp_path /tmp/proxy_temp_path; | ||
fastcgi_temp_path /tmp/fastcgi_temp; | ||
uwsgi_temp_path /tmp/uwsgi_temp; | ||
scgi_temp_path /tmp/scgi_temp; | ||
server { | ||
listen 8080; | ||
server_name localhost; | ||
location /v1/policy/list { | ||
include cache_config.conf; | ||
include common_proxy.conf; | ||
proxy_cache_key "$request_uri|$http_x_whylabs_organization"; | ||
} | ||
location /v1/organizations/managed-organizations { | ||
include cache_config.conf; | ||
include common_proxy.conf; | ||
proxy_cache_key "$request_uri|$http_x_whylabs_organization"; | ||
} | ||
location /v1/policy { | ||
include cache_config.conf; | ||
include common_proxy.conf; | ||
proxy_cache_key "$request_uri|$http_x_whylabs_organization"; | ||
} | ||
location /v1/api-key/validate { | ||
include cache_config.conf; | ||
include common_proxy.conf; | ||
proxy_cache_key "$request_uri|$http_x_api_key"; | ||
} | ||
location / { | ||
include common_proxy.conf; | ||
} | ||
} | ||
} | ||
cache_config.conf: | | ||
proxy_cache my_cache; | ||
proxy_cache_valid 200 403 {{ .Values.cache.duration }}; | ||
proxy_cache_use_stale error timeout http_500 http_502 http_503 http_504; | ||
add_header X-Cache-Status $upstream_cache_status always; | ||
common_proxy.conf: | | ||
proxy_pass https://{{ .Values.cache.endpoint }}; | ||
proxy_set_header Host {{ .Values.cache.endpoint }}; | ||
proxy_set_header X-Real-IP $remote_addr; | ||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
proxy_set_header X-Forwarded-Proto $scheme; | ||
proxy_set_header Accept $http_accept; | ||
proxy_set_header Accept-Encoding $http_accept_encoding; | ||
proxy_set_header X-API-Key $http_x_api_key; | ||
proxy_set_header X-WhyLabs-Organization $http_x_whylabs_organization; | ||
{{- end }} |
Oops, something went wrong.