Skip to content

Instantly share code, notes, and snippets.

@vdel26
Last active February 26, 2021 18:57
Show Gist options
  • Select an option

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

Select an option

Save vdel26/d313effbb57500d3827d to your computer and use it in GitHub Desktop.
Referrer filter detection in 3scale API proxy
# ENABLING REFERRER FILTERING IN NGINX – by IP address
# Using this snippet, 3scale will check if the origin of the API call
# matches the one introduce for that application by the developer
# Nginx will report to 3scale the origin IP address.
# replace the following location block in your nginx.conf file
location = /threescale_authrep {
internal;
set $provider_key "YOUR_PROVIDER_KEY";
proxy_pass http://threescale_backend/transactions/authrep.xml?provider_key=$provider_key&service_id=$service_id&$usage&$credentials&referrer=$remote_addr;
proxy_set_header Host "su1.3scale.net";
proxy_set_header X-3scale-User-Agent "nginx$deployment";
}
# ENABLING REFERRER FILTERING IN NGINX – by Referer header
# Using this snippet, 3scale will check if the origin of the API call
# matches the one introduce for that application by the developer
# Nginx will take the data from the 'Referer' header (http://tools.ietf.org/html/rfc7231#section-5.5.2)
# replace the following location block in your nginx.conf file
location = /threescale_authrep {
internal;
set $provider_key "YOUR_PROVIDER_KEY";
proxy_pass http://threescale_backend/transactions/authrep.xml?provider_key=$provider_key&service_id=$service_id&$usage&$credentials&referrer=$http_referer;
proxy_set_header Host "su1.3scale.net";
proxy_set_header X-3scale-User-Agent "nginx$deployment";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment