-
Notifications
You must be signed in to change notification settings - Fork 125
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 #197 from euanh/canary-test
nginx: Add test for canary deployment
- Loading branch information
Showing
2 changed files
with
187 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
[ | ||
{ | ||
"name": "blue", | ||
"hosts": [ | ||
"demo.example.com" | ||
], | ||
"targets": [ | ||
"10.0.0.1:80" | ||
], | ||
"port": 80 | ||
}, | ||
{ | ||
"name": "green", | ||
"hosts": [ | ||
"demo.example.com" | ||
], | ||
"targets": [ | ||
"192.168.0.1:80" | ||
], | ||
"port": 80 | ||
} | ||
] |
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,165 @@ | ||
# interlock config version | ||
user nginx; | ||
worker_processes 1; | ||
|
||
|
||
|
||
error_log /dev/stdout warn; | ||
pid /var/run/proxy.pid; | ||
|
||
|
||
events { | ||
worker_connections 1024; | ||
} | ||
|
||
http { | ||
include /etc/nginx/mime.types; | ||
default_type application/octet-stream; | ||
server_names_hash_bucket_size 128; | ||
|
||
|
||
|
||
log_format main '$remote_addr - $remote_user [$time_local] "$request" ' | ||
'$status $body_bytes_sent "$http_referer" ' | ||
'"$http_user_agent" "$http_x_forwarded_for"'; | ||
|
||
log_format trace '$remote_addr - $remote_user [$time_local] "$request" $status ' | ||
'$body_bytes_sent "$http_referer" "$http_user_agent" ' | ||
'"$http_x_forwarded_for" $request_id $msec $request_time ' | ||
'$upstream_connect_time $upstream_header_time $upstream_response_time'; | ||
|
||
access_log /dev/stdout main; | ||
|
||
sendfile on; | ||
#tcp_nopush on; | ||
|
||
keepalive_timeout 75s; | ||
client_max_body_size 1m; | ||
client_body_buffer_size 8k; | ||
client_header_buffer_size 1k; | ||
large_client_header_buffers 4 8k; | ||
client_body_timeout 60s; | ||
underscores_in_headers off; | ||
|
||
add_header x-request-id $request_id; | ||
add_header x-proxy-id $hostname; | ||
add_header x-server-info "interlock/2.0.0-dev (HEAD) linux/amd64"; | ||
add_header x-upstream-addr $upstream_addr; | ||
add_header x-upstream-response-time $upstream_response_time; | ||
|
||
proxy_connect_timeout 600; | ||
proxy_send_timeout 600; | ||
proxy_read_timeout 600; | ||
proxy_set_header X-Real-IP $remote_addr; | ||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
proxy_set_header Host $http_host; | ||
proxy_set_header x-request-id $request_id; | ||
send_timeout 600; | ||
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504; | ||
|
||
ssl_prefer_server_ciphers on; | ||
ssl_ciphers HIGH:!aNULL:!MD5; | ||
ssl_protocols TLSv1.2; | ||
|
||
|
||
map $http_upgrade $connection_upgrade { | ||
default upgrade; | ||
'' close; | ||
} | ||
|
||
|
||
# default host return 503 | ||
server { | ||
listen 80 default_server; | ||
server_name _; | ||
|
||
root /usr/share/nginx/html; | ||
|
||
error_page 503 /50x.html; | ||
location = /50x.html { | ||
try_files /50x.html @error; | ||
internal; | ||
} | ||
|
||
location @error { | ||
root /usr/share/nginx/html; | ||
} | ||
|
||
location / { | ||
return 503; | ||
} | ||
|
||
location /nginx_status { | ||
stub_status on; | ||
access_log off; | ||
} | ||
} | ||
|
||
|
||
|
||
|
||
|
||
upstream up-demo.example.com { | ||
zone up-demo.example.com_backend 64k; | ||
|
||
|
||
server 10.0.0.1:80; | ||
|
||
|
||
server 192.168.0.1:80; | ||
|
||
|
||
} | ||
|
||
server { | ||
listen 80; | ||
server_name demo.example.com; | ||
|
||
|
||
|
||
|
||
|
||
location / { | ||
proxy_pass http://up-demo.example.com; | ||
} | ||
|
||
|
||
|
||
|
||
location /nginx_status { | ||
stub_status on; | ||
access_log off; | ||
} | ||
|
||
} | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
include /etc/nginx/conf.d/*.conf; | ||
} | ||
|
||
stream { | ||
# main log compatible format | ||
log_format stream '$remote_addr - - [$time_local] "$ssl_preread_server_name -> $name ($protocol)" ' | ||
'$status $bytes_sent "" "" "" '; | ||
|
||
map $ssl_preread_server_name $name { | ||
|
||
} | ||
|
||
|
||
|
||
|
||
server { | ||
listen 443; | ||
proxy_pass $name; | ||
proxy_protocol on; | ||
ssl_preread on; | ||
access_log /dev/stdout stream; | ||
} | ||
} |