Limits on a service's traffic
Cap how many requests one visitor can send to a web service, ask every visitor for a password, and block a source, all enforced before a request reaches it.
A web service can turn requests away at Dekka's edge, before they reach your code, so one client sending thousands of requests a second can't take a small service down.
Limit each visitor's requests
Open the service's Settings, and under Networking turn on Limit each visitor's requests. Choose how many requests one visitor may make and whether that is per second or per minute, then save. The limit is applied to the running service within a minute, without a deploy and without restarting it, and turning it off works the same way.
A visitor is counted by the address their requests come from. They may use the whole allowance at once, and then wait for it to refill over the period you chose. A request over the limit gets 429 Too Many Requests and never reaches your service, and it appears in the service's Requests with that status, so you can see how often the limit is used.
Many people in Ghana share one mobile network address, and so do the people in an office behind one connection, so a limit that is too low refuses real visitors. The limit starts at 600 requests a minute, which leaves room for that. Lower it only if you know who sends your traffic.
In the API the limit is the service spec's networking.rate_limit, for example {"requests": 600, "period": "minute"}, or null for no limit. A request of 1 to 100,000 is accepted, and only an application, which has a public address, can have one.
Ask visitors for a password
A staging site or a preview can be kept private with a password, which every visitor gives before the site loads. It guards your own site and has nothing to do with signing in to Dekka.
Under Networking in the service's settings, turn on Ask visitors for a password, choose the name visitors give (it starts as dekka) and a password of at least 8 characters, and choose Save password. Browsers ask for the name and password in their own sign-in box, and remember them for the visit. It applies within a minute on every address the service has, its apps.dekka.cloud address and your own domains, without a deploy. Change the password replaces it, and turning the switch off lets anyone in again.
Dekka keeps only a bcrypt hash of the password and never shows it again, so keep it somewhere safe. A request without the right password gets 401 Unauthorized and never reaches your service, and the password is taken off the request before your service sees it. Your service's own health checks are unaffected, because they reach it directly.
In the API, PUT /v1/resources/{resource_id}/password with {"username": "dekka", "password": "..."} sets it, DELETE on the same path removes it, and a service's password_protection names the user while it is on.
Block a source
When Dekka Sentry finds a source scanning your paths or guessing passwords, its finding shows the source's address and offers Block this source. Choose how long the block lasts, a day, a week or until someone unblocks it, and every request from that address to the project's web services gets 403 Forbidden within seconds, before it reaches them. A blocked source isn't counted against a rate limit or asked for a password.
Many people in Ghana share one mobile network address, so blocking an address may block other people behind it. A block for a day is usually enough to stop an attack while you fix what it found.
The project's Sentry page lists its blocked sources, who blocked each, when, and until when, with Unblock beside each. Blocking and unblocking need an owner or an admin signed in to the dashboard, never an API key, so a stolen key can't block your visitors or let an attacker back in. Both appear in the organisation's activity.
In the API, POST /v1/projects/{project_id}/blocked-sources with {"source": "41.66.1.9", "duration": "day"} blocks an address or a range no wider than a /16, GET on the same path lists them, and DELETE /v1/projects/{project_id}/blocked-sources/{id} unblocks one. Up to 200 sources a project can be blocked at once.