7. Express behind proxies

Express behind proxies

When running an Express app behind a proxy, set (by using app.set()) the application variable trust proxy to one of the values listed in the following table.

Although the app will not fail to run if the application variable trust proxy is not set, it will incorrectly register the proxy’s IP address as the client IP address unless trust proxy is configured.

Type Value
Boolean

If true, the client’s IP address is understood as the left-most entry in the X-Forwarded-* header.

If false, the app is understood as directly facing the Internet and the client’s IP address is derived from req.connection.remoteAddress. This is the