> ## Documentation Index
> Fetch the complete documentation index at: https://docs.stackshift.cloud/llms.txt
> Use this file to discover all available pages before exploring further.

# Get the visitor’s real IP

> Read the visitor’s IP from X-Forwarded-For, or turn on the PROXY protocol for domains whose HTTPS is forwarded untouched.

## Goal

Make logs, rate limits and allow-lists in your app see the real client address.

## Prerequisites

* A domain added in Networking.

## Workflow

**Step 1**

With StackShift handles HTTPS, or on port 80, read X-Forwarded-For. Nothing to turn on.

**Step 2**

With Forward HTTPS untouched, configure your web server to accept the PROXY protocol on port 443.

**Step 3**

Then edit the domain in Networking and turn on Pass the visitor’s real IP.

## What each mode sends

* StackShift handles HTTPS: plain HTTP to your App port with X-Forwarded-For, X-Forwarded-Proto: https and X-Forwarded-Host.
* Forward HTTPS untouched, port 80: X-Forwarded-For and X-Forwarded-Proto: http.
* Forward HTTPS untouched, port 443: the encrypted connection is not opened, so no header can be added. With Pass the visitor’s real IP on, each connection starts with a PROXY protocol version 2 header that carries the visitor’s address.
* With HTTPS forwarded untouched, IPv6 visitors reach the server directly through the AAAA record, so their own address is the client address and no header is added. With StackShift handling HTTPS, IPv6 visitors go through the edge like IPv4 visitors and arrive with X-Forwarded-For.

## Turn the PROXY protocol on in the right order

A web server that does not expect the PROXY header fails every HTTPS request when the header arrives, and one that requires it fails when it is missing. Configure the web server first, then turn on Pass the visitor’s real IP. The switch is offered only for Forward HTTPS untouched.

Trust the forwarded address only from the StackShift edge, never from the whole internet. Edge connections reach your server over IPv6 from the machine it runs on. Networking shows that address under the PROXY switch and the App port as the only one to trust; allow only it.

```nginx nginx theme={null}
server {
    listen 443 ssl proxy_protocol;
    set_real_ip_from EDGE_ADDRESS;
    real_ip_header proxy_protocol;
}

server {
    listen 80;
    set_real_ip_from EDGE_ADDRESS;
    real_ip_header X-Forwarded-For;
}
```

```text Caddyfile theme={null}
{
    servers :443 {
        listener_wrappers {
            proxy_protocol {
                allow EDGE_ADDRESS
            }
            tls
        }
    }
}
```

```yaml Traefik static configuration theme={null}
entryPoints:
  websecure:
    address: ":443"
    proxyProtocol:
      trustedIPs:
        - "EDGE_ADDRESS"
  web:
    address: ":80"
    forwardedHeaders:
      trustedIPs:
        - "EDGE_ADDRESS"
```

## Apps behind StackShift handles HTTPS

Frameworks read the client IP from X-Forwarded-For only when the proxy is trusted. For example, set trust proxy in Express, TrustProxies in Laravel, or --forwarded-allow-ips in Gunicorn and Uvicorn.

## Expected result

> [!TIP]
>
> Your access logs show the visitor’s address instead of the StackShift edge.

## Common failures

> [!WARNING]
>
> * Every HTTPS request fails right after turning the switch on: the web server is not listening with the PROXY protocol on 443. Turn the switch off, fix the configuration, then turn it on again.
> * Logs still show the edge address: the trusted address in set\_real\_ip\_from, allow or trustedIPs does not match the address the edge connects from.

## Related guides

> [card] [Domains and HTTPS](https://docs.stackshift.cloud/compute/custom-domains.md)
>
> Point your own domain at a VPS, prove it with a TXT record, and choose per domain whether StackShift handles HTTPS or forwards it untouched.

> [card] [Use a VPS with Coolify or Dokploy](https://docs.stackshift.cloud/compute/coolify-and-dokploy.md)
>
> Install Coolify or Dokploy at order time, forward HTTPS untouched to its proxy, and use the server’s wildcard name or your own domains for apps.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.