This repository has been archived by the owner on Jan 12, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnginx.conf
46 lines (40 loc) · 1.59 KB
/
nginx.conf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
worker_processes 1;
error_log logs/error.log debug_http;
events {
worker_connections 10;
}
http {
include mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent ref: "$http_referer" '
'"$http_user_agent" "$
server {
listen 8183;
server_name 127.0.0.1;
proxy_redirect off;
proxy_set_header host $http_host;
proxy_set_header x-real-ip $remote_addr;
set $apiMime "$http_accept";
# Figure out whether we're supposed to extract information from the URI
if ($uri ~ ^.*\.(v\d)\.(xml|json)$) {
set $apiVersion $1;
set $apiMime "application/$2;charset=utf-8";
# Use the version information from the URL to proxy to the right
# instance and strip the version and mime type information before
# proxying to the actual service
rewrite ^(.*)/(\w*).*$ $1/$apiVersion/$2 last;
}
# Figure out whether we're supposed to extract information from the Accept header
if ($http_accept ~ ^application/vnd\.chids\.versioning-(v\d)\+(xml|json)) {
set $apiVersion $1;
# Use the version information from the accept header to proxy to
# the right instance
rewrite ^(.*)/(\w*)$ $1/$apiVersion/$2 last;
}
proxy_set_header Accept $apiMime;
location / {
proxy_pass http://127.0.0.1:8080;
}
}
}