Skip to content

Instantly share code, notes, and snippets.

@vdel26
Last active August 29, 2015 14:05
Show Gist options
  • Select an option

  • Save vdel26/3b9ce61ee92a8debf1d3 to your computer and use it in GitHub Desktop.

Select an option

Save vdel26/3b9ce61ee92a8debf1d3 to your computer and use it in GitHub Desktop.
Bypass 3scale depending on incoming IP
upstream backend_api {
# service name:API ;
server api.domain.com:80 max_fails=5 fail_timeout=30;
}
#### add this anywhere inside your http block
geo $match {
default 0;
## set IPs or IP groups that will be sent directly to your API
## http://nginx.org/en/docs/http/ngx_http_geo_module.html
1.2.3.4/32 1;
4.3.2.1/32 1;
}
####
location / {
set $provider_key null;
set $cached_key null;
set $credentials null;
set $usage null;
set $service_id 1234567890;
set $proxy_pass null;
set $secret_token null;
proxy_ignore_client_abort on;
#### add this snippet to your "location /" block
if ($match) {
proxy_pass http://backend_api;
}
####
access_by_lua_file lua_tmp.lua;
proxy_pass $proxy_pass;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host weather.yahooapis.com;
proxy_set_header X-3scale-proxy-secret-token $secret_token;
add_header X-3scale-proxy-secret-token $secret_token;
post_action /out_of_band_authrep_action;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment