This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| upstream production_upstream { | |
| server production-environment-url-with-port max_fails=5 fail_timeout=30; | |
| } | |
| upstream sandbox_upstream { | |
| server sandbox-environment-url-with-port max_fails=5 fail_timeout=30; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| listen 80; | |
| ## CHANGE YOUR SERVER_NAME TO YOUR CUSTOM DOMAIN OR LEAVE IT BLANK IF ONLY HAVE ONE | |
| server_name YOUR-SERVICE-DOMAIN-FOR-NGINX; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ## CHANGE THE PATH TO POINT TO THE RIGHT FILE ON YOUR FILESYSTEM | |
| access_by_lua_file LUA-SYSTEM-PATH; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- if is_known ~= 200 then | |
| local res = ngx.location.capture("/threescale_authrep", { share_all_vars = true }) | |
| -- -- IN HERE YOU DEFINE THE ERROR IF CREDENTIALS ARE PASSED, BUT THEY ARE NOT VALID | |
| -- if res.status ~= 200 then | |
| -- -- remove the key, if it's not 200 let's go the slow route, to 3scale's backend | |
| -- api_keys:delete(ngx.var.cached_key) | |
| -- ngx.status = res.status | |
| -- ngx.header.content_type = "application/json" | |
| -- error_authorization_failed(service) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| local s = ngx.re.match(res.body,[=[<plan>Sandbox]=]) | |
| local p = ngx.re.match(res.body,[=[<plan>Production]=]) | |
| if p then | |
| ngx.var.proxy_pass = "http://production_upstream" | |
| elseif s then | |
| ngx.var.proxy_pass = "http://sandbox_upstream" | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import threescale; | |
| set req.http.X-tmp = threescale.send_get_request_threaded(“su1.3scale.net”,“80”,req.url,""); | |
| set req.http.X-tmp = threescale.send_get_request(“su1.3scale.net”,“80”,req.url,“X-ur-header: true;”); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ab -c 1 -n 1 http://127.0.0.1:8080/transactions/authrep.xml?provider_key=PROVIDER_KEY&app_id=APP_ID&app_key=APP_KEY&%5Busage%5D%5Bhits%5D=1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| {% for feature in current_user.account.bought_account_plan.system_name %} | |
| ... | |
| {% endfor %} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| {% if current_account %} | |
| {% if current_account.credit_card_required? and current_account.credit_card_missing? %} | |
| <div class="missing_card"> | |
| <p>You have selected a paid API plan. | |
| Please <a href="{{ urls.payment_details }}">enter your credit card</a> | |
| to get access to your API key.</p> | |
| </div> | |
| {% endif %} | |
| {% endif %} |