Skip to content

Commit 70b1512

Browse files
authored
Merge pull request #197 from euanh/canary-test
nginx: Add test for canary deployment
2 parents e66097d + 0cc4217 commit 70b1512

2 files changed

Lines changed: 187 additions & 0 deletions

File tree

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
[
2+
{
3+
"name": "blue",
4+
"hosts": [
5+
"demo.example.com"
6+
],
7+
"targets": [
8+
"10.0.0.1:80"
9+
],
10+
"port": 80
11+
},
12+
{
13+
"name": "green",
14+
"hosts": [
15+
"demo.example.com"
16+
],
17+
"targets": [
18+
"192.168.0.1:80"
19+
],
20+
"port": 80
21+
}
22+
]
Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
# interlock config version
2+
user nginx;
3+
worker_processes 1;
4+
5+
6+
7+
error_log /dev/stdout warn;
8+
pid /var/run/proxy.pid;
9+
10+
11+
events {
12+
worker_connections 1024;
13+
}
14+
15+
http {
16+
include /etc/nginx/mime.types;
17+
default_type application/octet-stream;
18+
server_names_hash_bucket_size 128;
19+
20+
21+
22+
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
23+
'$status $body_bytes_sent "$http_referer" '
24+
'"$http_user_agent" "$http_x_forwarded_for"';
25+
26+
log_format trace '$remote_addr - $remote_user [$time_local] "$request" $status '
27+
'$body_bytes_sent "$http_referer" "$http_user_agent" '
28+
'"$http_x_forwarded_for" $request_id $msec $request_time '
29+
'$upstream_connect_time $upstream_header_time $upstream_response_time';
30+
31+
access_log /dev/stdout main;
32+
33+
sendfile on;
34+
#tcp_nopush on;
35+
36+
keepalive_timeout 75s;
37+
client_max_body_size 1m;
38+
client_body_buffer_size 8k;
39+
client_header_buffer_size 1k;
40+
large_client_header_buffers 4 8k;
41+
client_body_timeout 60s;
42+
underscores_in_headers off;
43+
44+
add_header x-request-id $request_id;
45+
add_header x-proxy-id $hostname;
46+
add_header x-server-info "interlock/2.0.0-dev (HEAD) linux/amd64";
47+
add_header x-upstream-addr $upstream_addr;
48+
add_header x-upstream-response-time $upstream_response_time;
49+
50+
proxy_connect_timeout 600;
51+
proxy_send_timeout 600;
52+
proxy_read_timeout 600;
53+
proxy_set_header X-Real-IP $remote_addr;
54+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
55+
proxy_set_header Host $http_host;
56+
proxy_set_header x-request-id $request_id;
57+
send_timeout 600;
58+
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
59+
60+
ssl_prefer_server_ciphers on;
61+
ssl_ciphers HIGH:!aNULL:!MD5;
62+
ssl_protocols TLSv1.2;
63+
64+
65+
map $http_upgrade $connection_upgrade {
66+
default upgrade;
67+
'' close;
68+
}
69+
70+
71+
# default host return 503
72+
server {
73+
listen 80 default_server;
74+
server_name _;
75+
76+
root /usr/share/nginx/html;
77+
78+
error_page 503 /50x.html;
79+
location = /50x.html {
80+
try_files /50x.html @error;
81+
internal;
82+
}
83+
84+
location @error {
85+
root /usr/share/nginx/html;
86+
}
87+
88+
location / {
89+
return 503;
90+
}
91+
92+
location /nginx_status {
93+
stub_status on;
94+
access_log off;
95+
}
96+
}
97+
98+
99+
100+
101+
102+
upstream up-demo.example.com {
103+
zone up-demo.example.com_backend 64k;
104+
105+
106+
server 10.0.0.1:80;
107+
108+
109+
server 192.168.0.1:80;
110+
111+
112+
}
113+
114+
server {
115+
listen 80;
116+
server_name demo.example.com;
117+
118+
119+
120+
121+
122+
location / {
123+
proxy_pass http://up-demo.example.com;
124+
}
125+
126+
127+
128+
129+
location /nginx_status {
130+
stub_status on;
131+
access_log off;
132+
}
133+
134+
}
135+
136+
137+
138+
139+
140+
141+
142+
143+
include /etc/nginx/conf.d/*.conf;
144+
}
145+
146+
stream {
147+
# main log compatible format
148+
log_format stream '$remote_addr - - [$time_local] "$ssl_preread_server_name -> $name ($protocol)" '
149+
'$status $bytes_sent "" "" "" ';
150+
151+
map $ssl_preread_server_name $name {
152+
153+
}
154+
155+
156+
157+
158+
server {
159+
listen 443;
160+
proxy_pass $name;
161+
proxy_protocol on;
162+
ssl_preread on;
163+
access_log /dev/stdout stream;
164+
}
165+
}

0 commit comments

Comments
 (0)