Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: elaborate on X-Forwarded-For header #314

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions docs/deployment-environment.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ icon: "box"
Deployments run in AWS ECS with Fargate VMs.
The default compute configuration is 0.25 vCPU and 0.5 GB RAM.
This will soon be made configurable.
If you need more compute out of the gate, reach out to us.
If you need more compute out of the gate, [reach out to us.](https://www.shuttle.dev/contact)

**Rolling deployments**:
When a new deployment is made, it will be started alongside the previous one until it is considered healthy.
Expand All @@ -23,7 +23,12 @@ If the new deployment fails to become healthy, it will be retried 3 times while

HTTPS traffic is proxied to your app on the project's default subdomain and any [custom domains]() that have been added.

The proxy sets the `X-Forwarded-For` HTTP header on incoming requests to the remote IP address of the request.
### Request Headers

#### X-Forwarded-For
`X-Forwarded-For` is a header that allows you to get the original IP of the HTTP request. Deployed Shuttle projects sit behind a proxy, meaning that when you try to get the IP address normally you may end up with the proxy IP instead of the requester IP. With the `X-Forwarded-For` header, you can now always get the requester IP by parsing the given header value.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we make it a bit more concise, perhaps like this?

Suggested change
`X-Forwarded-For` is a header that allows you to get the original IP of the HTTP request. Deployed Shuttle projects sit behind a proxy, meaning that when you try to get the IP address normally you may end up with the proxy IP instead of the requester IP. With the `X-Forwarded-For` header, you can now always get the requester IP by parsing the given header value.
Deployed Shuttle projects sit behind a proxy, so if you extract the peer address of the incoming connection in your application, it will be the address of our proxy. To allow you to get the IP address of the original client, the Shuttle proxy will set it in the `X-Forwarded-For` (link to the mdn docs for the header here) header in all requests to your project.

We are also using the header incorrectly, it should be a comma separated list of IPs, including the IP of our proxy. If it's just the original client IP, we should have a new custom header, as I understand it. But we can address that later.


To implement your own custom rate limiting, our [blog post on how to write API rate limiting yourself](https://www.shuttle.dev/blog/2024/02/22/api-rate-limiting-rust) may prove useful. You can also additionally implement your own middleware that utilises the `governor` crate, as seen on [`tower-governor`](https://docs.rs/tower_governor/latest/tower_governor/) and [`actix-governor`](https://docs.rs/actix-governor/latest/actix_governor/).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if this is the right place to link to rate limiting guides, as it's not the only use-case. I feel it would be more appropriate to link to the documentation for this header in the rate limiting guides themselves.


## Environment variables

Expand All @@ -44,4 +49,3 @@ See [Shuttle Secrets](/resources/shuttle-secrets)
## Customize Runtime container

See [Hook scripts](/docs/builds#experimental-hook-scripts)

Loading