updates
This commit is contained in:
15
README.md
15
README.md
@ -30,12 +30,12 @@ RewriteCond %{REQUEST_FILENAME} !-f
|
||||
RewriteRule ^ index.php [L]
|
||||
```
|
||||
|
||||
**nginx**:
|
||||
**nginx**: use the included [`nginx.conf`](nginx.conf), which goes inside your `http` block (e.g. in `sites-enabled`). It:
|
||||
|
||||
```nginx
|
||||
location ~ ^/(urls|last)\.txt$ { deny all; }
|
||||
location / { try_files $uri /index.php?$query_string; }
|
||||
```
|
||||
- sends every request to `index.php`, so nothing else in the directory (`urls.txt`, `.git`, …) is served directly
|
||||
- rate-limits each IP to 10 requests/second (burst 20) overall, and to 10/minute (burst 5) for creating links or trying passwords. Over-limit requests get `429`.
|
||||
|
||||
It expects an `upstream php { ... }` pointing at PHP-FPM. If nginx is behind another proxy, uncomment the `real_ip` lines. Otherwise every visitor shares the proxy's rate limit.
|
||||
|
||||
**Local development** (PHP's built-in server, using `index.php` as the router):
|
||||
|
||||
@ -54,8 +54,13 @@ php -S localhost:4000 index.php
|
||||
| `$max_url_length` | `100` | Longer URLs are rejected. |
|
||||
| `$charset` | (shuffled) | Characters used in keys. Don't change it once links exist. |
|
||||
| `$enable_test` | `false` | Turns on the key-generation test form. |
|
||||
| `$auth_cookie`, `$auth_cookie_days` | `shortener_auth`, `365` | Cookie that remembers a correct password, and how long it lasts. |
|
||||
| `$urls_file`, `$last_file` | `urls.txt`, `last.txt` | Where the data is stored. |
|
||||
|
||||
### Remembered password
|
||||
|
||||
If you tick **Remember me for a year** when entering the correct password, the app sets a cookie that lasts one year. While it's valid, the form doesn't ask for the password and a **Log out** link appears at the bottom of the page. Logging out clears the cookie. The cookie holds an HMAC token derived from the password, not the password itself, so changing `$password` signs everyone out. The cookie is only accepted on POST requests, so a link to `/?url=...` on another site can't create links using your cookie.
|
||||
|
||||
## API
|
||||
|
||||
Shorten a URL from the command line. The response is plain text:
|
||||
|
||||
Reference in New Issue
Block a user