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