-
Notifications
You must be signed in to change notification settings - Fork 192
Custom Headers
You can easily add or remove headers from a proxy rule by editing the proxy rule and select "Custom Headers" options in the "Advanced Settings" field.
In the side panel, you will see a few options to add or remove custom headers.
The blue arrow means the header is added or removed when the request is proxying from Zoraxy to your upstream / origin servers. Which means if the request from your downstream client devices like browser, the header will get modified by this rule.
The opposite goes for the orange arrow. The orange arrow means the header is added or removed when the request is proxying from your upstream server to downstream (client). This option will modify the respond header of your upstream origin server and send it to the downstream device like a web browser.
Some variables can be used in the value field of a header to modify the downstream to upstream request (aka the blue arrow direction). Require Zoraxy v3.1.2 or above.
-
$host
: Represents the hostname from the request. This is the domain name or IP address in the URL (e.g.,example.com
). -
$remote_addr
: The client’s IP address. This shows the source address from which the request originated. -
$request_uri
: The full requested URI, including the path and query string (e.g.,/path/to/resource?arg=value
). This is often useful for logging or URL-based rules. -
$request_method
: The HTTP method used in the request, likeGET
,POST
,PUT
, etc. -
$content_length
: The size of the request body in bytes, as specified by theContent-Length
header. Useful for checking if there’s content in a request (e.g., a file upload). -
$content_type
: The MIME type of the request body, such asapplication/json
ortext/html
. This can be used to process requests differently based on content type.
-
$uri
: The path part of the URL, excluding the scheme, host, and query string (e.g.,/path/to/resource
). This is the main part of the URL requested. -
$args
: The raw query string part of the URL (e.g.,arg=value&foo=bar
). Used if you need to work directly with the unparsed query data. -
$scheme
: The scheme of the URL (http
orhttps
). This can be useful for redirects or ensuring secure connections. -
$query_string
: Same as$args
, for compatibility reasons.
-
$http_user_agent
: The user agent string from the request, identifying the client software (e.g., browser or app) making the request. -
$http_referer
: The URL of the page that referred the client to this request. This can be used for tracking or enforcing access policies based on the referring page.
There are a few advance settings in place but in general cases, you should not be touching these unless you know what you are doing.
- Overwrite Host Header: Force overwrite all incoming request to a given hostname, use for legacy php projects that relies on hostname for routing.
- Remove Hop-by-hop Headers: Remove headers like Connection and Keep-Alive, mostly for debug purpose to check what Zoraxy is actually receiving from downstreams.