js_import batch-api.js; # keyval_zone for APIs where the last portion of the URI is an argument # The key is the portion of the URL before the last part set in the map keyval_zone zone=batch_api:64k state=/etc/nginx/state-files/batch-api.json; keyval $uri_prefix $batch_api zone=batch_api; # keyval_zone for APIs where the last portion of the URI is an argument # The key is the URI keyval_zone zone=batch_api2:64k state=/etc/nginx/state-files/batch-api2.json; keyval $uri $batch_api2 zone=batch_api2; # These maps are for breaking the URI into two parts for APIs where the # last part of the URI is an argument. For URIs of the form: # /// # $uri_prefix = // # $uri_suffix = map $uri $uri_prefix { ~^(?

.+)\/.+$ $p; } map $uri $uri_suffix { ~^.+\/(?.+)$ $s; } upstream api_servers { zone api_servers 64k; server 127.0.0.1:9080; server 127.0.0.1:9081; } upstream services { zone services 64k; server 127.0.0.1:9000; } server { listen 9000; location / { rewrite ^(.+)\/(.+)$ $1.php?item=$2 last; } location ~ \.php$ { proxy_pass http://api_servers; } } server { listen 80; set $batch_api_verbose on; location /batch-api { set $batch_api_arg_in_uri on; js_content batch-api.batchAPI; } location /batch-api2 { set $batch_api_arg_in_uri off; js_content batch-api.batchAPI; } location /myapi { proxy_pass http://services; } location /api { api write=on; # directives to restrict access to the API } } # vim: syntax=nginx