Skip to content

Instantly share code, notes, and snippets.

@toritori0318
Last active April 9, 2017 09:49
Show Gist options
  • Save toritori0318/2dc2b64ff696822b02d202bf1fc2f5b2 to your computer and use it in GitHub Desktop.
Save toritori0318/2dc2b64ff696822b02d202bf1fc2f5b2 to your computer and use it in GitHub Desktop.
request_id 引き回し
worker_processes 1;
events {
worker_connections 1024;
}
http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for" "$_request_id"';
# 80
#################################################
server {
listen 80;
include ../conf.d/x_request_id.conf;
access_log logs/access1.log main;
# add_header X-Request-ID $_request_id;
location / {
proxy_pass http://backend/fake;
proxy_set_header X-Request-ID $_request_id;
}
}
# local proxy fakeserver
#################################################
server {
listen 127.0.0.2:8080;
include ../conf.d/x_request_id.conf;
access_log logs/access2.log main;
# add_header X-Request-ID $_request_id;
location = /fake {
echo "this is the fake backend peer...";
}
}
upstream backend {
server 127.0.0.2:8080;
}
}
set $_request_id $request_id;
if ($http_x_request_id) {
set $_request_id $http_x_request_id;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment