OdooWiki OCA HUB

Proxy Trusted Hops

proxy_trusted_hops folder_open OCA/server-tools open_in_new
Tools License: LGPL-3

When proxy_mode is enabled, Odoo takes the client address from the X-Forwarded-For header, but it only trusts one proxy: it always takes the last address of the header. Behind more than one reverse proxy (for example a cloud load balancer in front of an ingress controller), that address is one of your own proxies, not the client.

This module lets you configure how many proxies Odoo trusts. Odoo then uses the address added by your outermost proxy, which is the real client.

This affects every place that uses the client address, for example the access log, the login log, the login cooldown after failed attempts, reCAPTCHA, and website visitors.

auto_awesome What this module does

AI-generated from the code · Odoo 16.0

Lets administrators tell Odoo how many reverse proxies sit in front of it, so the real client IP address is used instead of an internal proxy address when several proxies are chained.

This module changes how Odoo determines the client's IP address when it runs behind reverse proxies. By default Odoo trusts only one proxy and takes the last address in the X-Forwarded-For header; behind two or more proxies that address belongs to one of your own proxies, not the visitor.

The number of trusted proxies is read at server start from the environment variable ODOO_TRUSTED_PROXIES, or from a trusted_proxies option in a [proxy_trusted_hops] section of the configuration file (or of the server_environment configuration when that module is installed). If nothing is set, the value stays at 1, which is Odoo's standard behaviour.

  • If the value is not a positive whole number, an error is logged and Odoo falls back to trusting only one proxy.
  • When the value is greater than 1, Odoo is told to trust that many proxies for the forwarded client address, protocol and host.

There are no new menus, screens or models: the module only adjusts the web server layer. The effect is visible everywhere the client address is used, such as access logs, login logs, the login cooldown after failed attempts, reCAPTCHA and website visitor tracking. The change takes effect when the Odoo server starts, so a restart is needed after changing the setting.

Depends on

base

Text generated by AI (DeepSeek) from reading the Odoo 16.0 code on GitHub; it may contain mistakes, so check the code before deciding. View the code on GitHub

Availability by version

Reviewed: 2026-11-03
Confirmed (verified in repository and branch) Estimated (unverified) No information

Confirmation status: 1 confirmed, 8 with no information of 9 versions.

Sources · Odoo 16.0

Confirmed on 2026-11-03 in branch 16.0 of OCA/server-tools.

terminal Installation and usage

OCA documentation · Odoo 16.0

You don't have to install this module in a database. Add it to the server_wide_modules list so it is active as soon as the server starts:

server_wide_modules = base,web,proxy_trusted_hops

Set the number of reverse proxies in front of Odoo, either with the ODOO_TRUSTED_PROXIES environment variable or in a [proxy_trusted_hops] section of the Odoo configuration file:

[options]
proxy_mode = True

[proxy_trusted_hops]
trusted_proxies = 2

The environment variable takes precedence over the configuration file. When the server_environment module is on the addons path, the section is read through it, so it can also come from its environment files; the Odoo configuration file is still included there.

As in Odoo itself, the header is only used when proxy_mode is enabled and the request contains an X-Forwarded-Host header.

With trusted_proxies = N, Odoo uses the N-th address from the end of the X-Forwarded-For header. If the header contains fewer addresses than that, Odoo keeps the address of the connecting proxy.

Security warning: the client can send its own X-Forwarded-For header, and proxies only add their entry to it. Never set a value higher than the number of proxies that actually add an entry: otherwise the client decides which address Odoo sees, and can for example get around the login cooldown. Each proxy must add its entry to the header.

Check the server log at startup:

INFO ? odoo.addons.proxy_trusted_hops.patch: Trusting 2 proxies for the X-Forwarded-For header.

No verified information in OCA: Usage.

info

Data imported from GitHub: this sheet reflects the latest catalog review, not a live lookup. Always check the module documentation and staging before installing in production.