Home

ProxyPreserveHost

ProxyPreserveHost is a configuration option in Nginx's HTTP proxy module that governs how the Host header from a client request is treated when the request is proxied to an upstream server. When the directive is enabled, Nginx forwards the original Host header received from the client to the upstream; when it is disabled, Nginx may overwrite the Host header with the hostname of the upstream server or rely on explicit header configuration.

Why it matters: many applications rely on the Host header to perform virtual hosting, tenant routing, or

Context and usage: proxy_preserve_host can be set in http, server, or location blocks and accepts on or

Relation to other headers: aside from the Host header, reverse proxy configurations may add X-Forwarded-For and

host-based
features.
Preserving
the
client’s
Host
header
enables
upstream
services
to
see
the
external
domain
the
user
requested,
which
is
important
in
multi-tenant
or
domain-based
deployments.
off,
with
the
default
being
off
in
many
builds.
In
practice,
enabling
it
is
often
paired
with
careful
header
management—such
as
using
proxy_set_header
to
specify
Host
explicitly—to
ensure
the
upstream
receives
a
meaningful
value
and
to
avoid
exposing
internal
hostnames.
X-Forwarded-Proto
headers
to
pass
client
information.
Understanding
how
proxy_preserve_host
interacts
with
proxy_set_header
Host
is
important
when
configuring
proxies
that
front
multi-tenant
or
virtual-hosted
services.