Count per-address limits on the hop a trusted proxy added; limit signup
The limits read the leftmost X-Forwarded-For entry, which the client writes, and the LAN nginx appended to it. The address now comes from uvicorn's proxy-headers middleware (rightmost hop not in FORWARDED_ALLOW_IPS), applied in the app too so tunnel-replayed calls resolve the same way; nginx sets the header to $remote_addr and the compose backend trusts the Docker networks. /users/signup gets a per-address limit of 10 an hour.
This commit is contained in:
@@ -98,6 +98,11 @@ services:
|
||||
- FRONTEND_HOST=${FRONTEND_HOST?Variable not set}
|
||||
- ENVIRONMENT=${ENVIRONMENT}
|
||||
- BACKEND_CORS_ORIGINS=${BACKEND_CORS_ORIGINS}
|
||||
# Whose X-Forwarded-For is believed: Traefik's and the frontend's nginx,
|
||||
# which reach this from the compose networks (Docker's default pools sit
|
||||
# in 172.16.0.0/12). Both write the header themselves, so the hop they
|
||||
# add is the caller. No port is published here, so nothing else can.
|
||||
- FORWARDED_ALLOW_IPS=${FORWARDED_ALLOW_IPS:-127.0.0.1,172.16.0.0/12}
|
||||
- SECRET_KEY=${SECRET_KEY?Variable not set}
|
||||
- FIRST_SUPERUSER=${FIRST_SUPERUSER?Variable not set}
|
||||
- FIRST_SUPERUSER_PASSWORD=${FIRST_SUPERUSER_PASSWORD?Variable not set}
|
||||
|
||||
@@ -13,7 +13,10 @@ location /api {
|
||||
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
# Replaced, not appended to: whatever the client sent would otherwise sit
|
||||
# in front of the one hop the backend believes, and anything reading the
|
||||
# header naively would take it for the caller.
|
||||
proxy_set_header X-Forwarded-For $remote_addr;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
# The flow websocket (/api/v1/flows/ws) upgrades through here; passing the
|
||||
# client's own Connection header covers both it and ordinary requests.
|
||||
|
||||
Reference in New Issue
Block a user