How fail2ban stops brute force logins on Odoo
Fail2ban reads the failed login lines that Odoo writes to its log, counts repeated failures from the same IP address, and bans that address for a set time, so password guessing stops at the server or proxy before it reaches the login form again. A team needs this when the Odoo login page is reachable from the internet and password attempts arrive faster than staff would ever type them, but it has no reason to lock out legitimate users who mistype a password once or twice. The first step is not writing the jail. It is confirming the exact log line format for the Odoo version in use, because a filter regex built from one release's wording can silently match nothing after an upgrade. Check a few real failed attempts in your own log, note the fields that carry the client address and the login, and test the filter against that output before enabling any ban.
Fail2ban has limits you should plan around. It only sees failures it can attribute to an address, so it does nothing about a valid password that has been stolen and used from a normal-looking location, and it does little against attacks spread across a large number of addresses, each making only a few attempts. Those risks call for other controls such as Odoo's own login cooldown and CAPTCHA settings, strong password rules, two-factor authentication for staff accounts, and rate limits at the reverse proxy. If your Odoo sits behind a proxy, confirm which address the log records: without correct forwarding headers, every failure may appear to come from the proxy itself, and a ban would block your own traffic. Ask whoever runs your proxy to confirm the forwarded address setting before you rely on bans in production.
How a failed login travels from the proxy to a fail2ban ban
The trace starts when a client posts credentials to the reverse proxy, which forwards the request to Odoo. Odoo writes a failed-login line to its server log, and fail2ban's filter matches that line and extracts the client address. The jail counts matches inside its time window and, once the limit is reached, the firewall action bans the address. Check at the proxy boundary that Odoo logs the real visitor address, because if it logs the proxy's own address, the ban lands on the proxy.
Failed login path from the browser to a firewall ban on the Odoo host.
fail2ban versus Odoo's login cooldown, CAPTCHA and proxy limits
This table compares four controls that slow down password guessing against Odoo: fail2ban, Odoo's own cooldown, CAPTCHA and reverse proxy rate limits. Read each row to see where a control runs, what it sees, and where it can wrongly block a legitimate user. Exact Odoo setting names and defaults must be confirmed in the documentation for your installed version before you rely on them.
| Control | Where it runs | What it sees and blocks | What it can get wrong and when it fits |
|---|---|---|---|
| fail2ban with a jail | On the Odoo host, reading the log lines Odoo writes for failed logins | Repeated failed login entries from one source address, then a firewall ban for that address for a set time | Can ban a shared office or NAT address for everyone behind it. Fits when log lines reliably show the client address and you control the firewall. |
| Odoo login cooldown | Inside the Odoo server, applied per login attempt | Failed attempts against an account or from a source, then a delay before further attempts are accepted | Can lock out a real user who mistypes a password, and it does not stop attackers spreading attempts across accounts. Fits as a baseline that works without host access. Confirm the setting name and default for your version. |
| CAPTCHA on login | In the Odoo login flow, after the system decides a challenge is needed | Automated submissions that cannot solve the challenge, which raises the cost of scripted guessing | Adds friction for users, may fail for some browsers or assistive tools, and does not stop a determined attacker using a solving service. Fits public-facing databases with self-service signup or portal access. Confirm availability in your version. |
| Rate limits at the reverse proxy | In the proxy, such as Nginx, before requests reach Odoo | Request volume to the login path per client address, rejecting excess requests before Odoo processes them | Depends on the address Odoo sees, so the proxy must pass the real client address correctly, or every user looks like one client. Fits for protecting the login route and reducing load during floods. |
| Main takeaway | Layered use | Each control sees a different signal: log lines, application state, challenge response or request rate | Combine at least two layers, test each one with a deliberate failed login, and document who can lift a ban or reset a lockout. |
Setting up a fail2ban filter and jail for Odoo logins
This sequence builds a fail2ban filter that reads failed Odoo login entries, a jail that bans an address after repeated failures within a set window, and a firewall action that blocks the banned address. It ends with a controlled test and a tested rollback path.
Confirm the failed-login log line
On the Odoo server, find where Odoo writes its log: the file set by the logfile key in the configuration file, or the systemd journal if Odoo writes to standard output. From a browser, attempt one login to a test user with a wrong password, then search the log for the failure message. Record the exact wording, the timestamp format and the field holding the client address. If Odoo runs behind a reverse proxy, check whether the address logged is the proxy or the client, and confirm how your proxy settings handle forwarded addresses. Done when one failure produces one matching line that contains a client address, and you have written down the wording for your installed version.
Write the filter regex
Create a filter file, for example /etc/fail2ban/filter.d/odoo-auth.conf, with a failregex that matches the failed-login line you recorded. Use the HOST tag so fail2ban captures the client address from that line. Add a datepattern if the default timestamp detection does not match Odoo's format. Keep the pattern narrow so it matches only failed authentication messages. Done when the file loads without a syntax error in the next test step and the regex contains a single capture for the address.
Test the filter against sample log lines
Run fail2ban-regex with your Odoo log file and the new filter file. The output summarizes how many lines matched, how many were ignored and which addresses were captured. Compare the count with the failed logins you triggered in step one. Then run the same test against a log excerpt that contains only successful logins, which should produce zero matches. Adjust the regex or datepattern and repeat until failures match, successes do not, and the captured address is correct. Done when the summary shows the expected match count and no false positives.
Define the jail with thresholds and timing
In /etc/fail2ban/jail.local, add an odoo-auth section that sets enabled, filter, logpath and backend, plus the failure threshold (maxretry), the find window (findtime), the ban duration (bantime) and the port or ports that serve Odoo. Agree these values with your security team before you set them, since they decide how many failures trigger a ban and how long it lasts. Check the server clock and timezone against the timestamps in the Odoo log, because a mismatch shifts the find window and can make failures fall outside it. Odoo's own login cooldown and CAPTCHA act separately and should be confirmed in their own settings. Done when fail2ban-client -t reports that the configuration is valid.
Choose the firewall action
Select an action that matches the firewall on the host, such as nftables, iptables, firewalld or ufw, and set it in the jail. If a reverse proxy or load balancer receives the traffic, decide whether to ban at the edge, where the client address is visible, or on the Odoo host, and confirm that the ban covers the ports Odoo uses. Restarting fail2ban applies the change, so schedule it with the team that owns the firewall. Done when fail2ban-client get odoo-auth actions lists the action you chose and the firewall tooling confirms the action is installed.
Reload fail2ban and check jail status
Reload or restart the fail2ban service so it reads the new filter and jail, then run fail2ban-client status odoo-auth. The output shows whether the jail is active, the number of currently failed attempts and the list of banned addresses. Also check the fail2ban log for errors about the filter, the log path or the firewall action. Done when the jail appears in the status output as active, reports zero banned addresses before testing, and the service log shows no errors for the jail.
Trigger a controlled failed login
From a test address that no administrator depends on, submit wrong passwords for a test user until the failure count passes the threshold you set. Then run fail2ban-client status odoo-auth from the server and confirm the test address appears in the banned list. Check that the test address cannot load the login page and that a login from another address still works. Keep a console or out-of-band path to the server available before testing, so an administrator who is accidentally banned can recover. Done when the test address is banned, blocked at the firewall and unable to reach Odoo, and other users are unaffected.
Unban an address and roll back the jail
To release an address, run fail2ban-client set odoo-auth unbanip with the address. If the jail itself must be removed, set enabled to false in the odoo-auth section or delete the section, then reload fail2ban. Confirm the address is absent from the status output, the firewall rule for it is gone and the address can log in again. Keep this rollback path documented with the team that runs the server, so unbanning does not depend on one person. Done when the status output no longer lists the address, the firewall shows no block for it, and a login from that address succeeds.
Which control stops which attack
Each login attack leaves a different trace, so no single control covers all of them. Fail2ban works from failed-login log lines, Odoo's own settings slow automated guessing inside the application, and the proxy limits request volume before it reaches Odoo.
Slow guessing from one address
One source address tries passwords for one or more accounts, spacing attempts over time. A fail2ban jail that counts failed-login lines per source address and bans it after a set number of failures in a set window stops this pattern. What remains exposed is an attacker who stays below your threshold, or a shared office or carrier address whose legitimate users get banned together. Check that the jail reads the correct timestamps, since a timezone offset can place failures outside the window you configured. Confirm the ban duration with your security team.
Bursts from many addresses
The attacker spreads attempts across many source addresses, so each address stays under the per-IP threshold. A per-address jail alone does not count the total attempts against one account. Odoo's login cooldown after failed attempts and proxy rate limits on the login path slow this pattern down. What remains exposed is a distributed attack that stays within both limits for a long period. Ask your team to confirm whether the proxy can rate limit by path, and whether failures are also counted per account.
Stolen or reused valid passwords
The attacker logs in with a correct password obtained from another breach or a phishing page, so no failed-login line is written and fail2ban has nothing to count. Two-factor authentication is the control that covers this case, because the second factor is still required after the password is accepted. What remains exposed is any account, portal user or API path that does not enforce the second factor. Review which user types require 2FA and how existing API keys and sessions behave before relying on it.
Credential stuffing through rotating proxies
Automated tools try large lists of leaked username and password pairs through rotating proxy addresses, with few attempts from each address. Fail2ban rarely reaches its threshold for any single address, so it provides little protection here. CAPTCHA on login adds a step that most automated tools cannot complete without a solving service. What remains exposed is traffic that passes the CAPTCHA, and successful logins from unfamiliar locations, which fail2ban cannot see. Ask your team to confirm how CAPTCHA behaves on your Odoo version and how login alerts are sent.
Why timezone offsets can misplace bans and log matches
Fail2ban compares log timestamps against its own clock, so the timezone and time format must agree before any ban window is trusted. The find time (the window in which repeated failures are counted) and the ban time are both calculated from parsed timestamps. If Odoo writes local time, the proxy writes UTC, and the fail2ban host uses a third zone, failures can fall outside the window they belong to, or a ban can start and end at unexpected moments. During an audit, this shows up as counts that do not match what the login logs appear to show, which is hard to explain without knowing the offset.
Start by comparing three clocks: the timezone configured on the Odoo server, the timezone of the reverse proxy that writes access logs, and the timezone and synchronization state of the host running fail2ban. Confirm each with the system time and timezone settings on that machine, and confirm that all three sync to the same time source. Then check the exact timestamp format written by the installed Odoo version and by your proxy, and confirm that the fail2ban filter's date pattern parses it. Test with a deliberate failed login and read back the timestamp fail2ban recorded, rather than assuming the offset from documentation or from memory.
Record the results in your change notes, because the zones you find are the ones an auditor will ask about. If the three clocks differ, decide whether to align them on UTC or on one local zone, and make that change on every host before tuning the jail. Re-run the test after any OS, container or proxy upgrade, since default timezone and log formats can change without a visible warning. Treat the offset as something to measure in your own environment, not as a fixed value.
Setup by deployment: direct exposure, reverse proxy or Docker
With Odoo exposed directly, clients connect to the Odoo HTTP server without an intermediary, so the request that reaches Odoo carries the client's own address. Failed sign-ins are written to Odoo's server log, which goes to standard output or to the file named by the logfile setting. Confirm which of those your installation uses before pointing fail2ban at it.
- Log source: Read the file named by
logfile, or the service journal if Odoo writes to standard output under a service manager. Trigger one failed sign-in and confirm the exact wording of the line for your version before writing the filter. - Client address: The peer address in each log line is the attacker's address, so no forwarded-header configuration is needed.
- Firewall action: Ban the source address on every port Odoo answers on, including the
http_portvalue and any TLS listener, so the banned host cannot reach the login page. - Single choke point: All traffic passes through Odoo, so the jail is the only throttle on sign-in attempts unless you add rate limits at the host firewall.
- Test before trust: Use a failed login from an address outside your network and check that the ban appears against that address.
Before enabling the jail, confirm the log path, the failed-login line format and the port settings in the Odoo deployment documentation for your installed version.
Behind a reverse proxy such as Nginx, the TCP connection to Odoo comes from the proxy, so the address Odoo sees is usually the proxy's own address. The client address has to travel in a forwarded header, and Odoo has to read that header only from the proxy. If either step is missing, every failed login is recorded against the proxy address, and a ban aimed at that address cuts off all users.
- Log source: Use the Odoo log for failed sign-ins, because Odoo records the authentication failure. The proxy access log is useful for request-level patterns on the login path.
- Client address: Set the forwarded header, commonly
X-Forwarded-FororX-Real-IP, on the proxy location that serves Odoo. Confirm the Odoo setting that enables proxy mode and the trusted proxy handling for your version. - Trust boundary: Only the proxy should reach Odoo's HTTP port, so clients cannot spoof the header by connecting directly.
- Firewall action: Apply the ban on the host where the public ports are open, which is usually the proxy host. Exclude the proxy's own addresses and your internal networks from the ban list.
- Separate proxy limits: Rate limits configured at the proxy have their own settings and do not replace the failed-login jail.
After setup, fail a login from an outside address and confirm the banned address in the log is that client, not the proxy.
In Docker, Odoo runs inside a container, so the container runtime handles the log and the host's packet filter handles the published port. Both affect what fail2ban can read and what a ban actually blocks. The log location and the source address that reaches the container depend on the Docker version, the network mode and the logging driver, so confirm each one on the host you run.
- Log source: With the default JSON file logging driver, container logs sit in the Docker data directory. Find the path with
docker inspectand theLogPathfield, and confirm the driver withdocker info. Alternatively, write Odoo's log to a file on a host-mounted volume that fail2ban can read. - Client address: Docker translates published ports, and whether the original source address reaches Odoo depends on the network mode and any userland proxy. Test this on your host instead of assuming it.
- Firewall action: Docker inserts its own rules for published ports, which can bypass rules managed by tools such as UFW. Place the ban rules in the
DOCKER-USERchain so they apply before Docker's accept rules. - Proxy container: If Nginx runs in its own container, the forwarded-header and trust rules still apply, and the ban must target the port published by the public-facing container.
- Image changes: A new image can move the configuration file or change setting names, so confirm the keys for the image version you deploy.
Before enabling the jail, confirm the log path, the source address and the ban chain on the host with a test failure from an outside address.
Operational risks of banning logins by IP address
IP-based bans are a blunt control, and four failure modes matter most. Each can lock out legitimate staff or leave the login form unprotected without any visible error. The reviews below catch them before users or attackers do.
Shared office and VPN addresses
Many staff often leave the network through one public address, such as an office gateway or VPN concentrator. A few mistyped passwords from different people can then ban that address for everyone behind it. Before go-live, list the egress addresses your users share, confirm them with your network team, and add them to the fail2ban ignore list. Each week, review banned addresses and count how many distinct accounts failed from each one.
Reverse proxy address banned
If Odoo sees only the reverse proxy's address, every failed login is attributed to that one IP. The jail then bans the proxy, and all users, including administrators, lose access through it. Confirm that the proxy forwards the client address and that Odoo is configured to trust that header, for example through the proxy_mode setting. Test with a deliberate failed login from a known address and check that the ban entry names that address, not the proxy.
Bans that expire wrongly
A ban that lasts too short a time lets a persistent attacker return within minutes. A ban that never expires accumulates false positives until someone notices. Both the ban duration and the window in which failures are counted need deliberate values, written down with the reasons for them. Review the banned list on a schedule, remove stale entries, and document an unban procedure that help desk staff can follow without escalation.
Jail silently stops matching
A filter depends on the exact path and line format of Odoo's login log. A version upgrade, a changed logging setup or a new log location can leave the jail running with zero matches, and nothing alerts you. After each Odoo upgrade, run the filter against the current log with fail2ban-regex, then trigger a controlled set of failed logins and confirm the jail's match count rises. Alert when a jail shows no activity over a period you define.
Testing the ban before production traffic depends on it
Test the fail2ban setup on a staging copy of the Odoo database, behind the same reverse proxy configuration that production uses, before any production traffic depends on it. A ban rule that has never fired is an assumption, and the test should prove each step in the chain: the failed login line is written, the filter matches it, the jail bans the address, the ban lifts, and the alert or log entry appears. Use a staging copy created by database duplication with neutralization, as described in Odoo's on-premise documentation. Neutralization disables outgoing mail, scheduled actions and payment provider links, so the test cannot send email, trigger integrations or touch real customer or employee accounts.
Generate the failures from a test address that is not used by any staff member or integration, and make the count deliberate. Send a known number of wrong passwords for a test user on the staging database, then check the fail2ban status for that jail and confirm the address appears in the banned list. Confirm that a successful login from an unbanned address still works, and that the ban is removed when the bantime expires or when you unban it manually with the fail2ban client. Confirm the timestamps against the server clock and the Odoo log timezone, since offset errors are a common reason a test appears to pass but the production jail behaves differently. Check that the alert or log entry reaches the team that will act on it.
Record each result as evidence: the test date, the Odoo and fail2ban versions, the exact filter and jail files under test, the number of attempts, the observed ban and unban times, and the log excerpts. Repeat the test after any change to the proxy, the Odoo log format or the filter, and keep the record with your change tickets. Ask your reviewers to confirm which parts of the test environment match production, such as proxy headers and client address forwarding, because a test that sees the proxy address instead of the client address proves nothing about the real jail. Only move the configuration to production once every step has passed on the staging copy.
Limits to confirm in your Odoo version and environment
Four checks decide whether the fail2ban jail works and whether your edition and hosting type allow it. Confirm each item against the Odoo documentation for your version and against your own servers, rather than assuming the behavior described on this page. Settle these before you write any fail2ban configuration.
Failed-login log line
Odoo writes a log line for each rejected sign-in, and the fail2ban pattern is only as accurate as its match against that line. Confirm the exact wording and field order, the client address field, and the timestamp format and time zone for the installed version. Copy a failed attempt from your own log and test the pattern against it before enabling any jail, because a pattern that matches nothing leaves the login form unprotected without raising an error.
Built-in cooldown and CAPTCHA
Odoo has its own login protections, including a cooldown after failed attempts and CAPTCHA on login, and each has settings whose defaults can change between releases. Confirm which settings exist in your version, their current values in your configuration, and whether they apply to the same login endpoint that fail2ban watches. Record the values so the team knows which protection stops which attempt, and what a legitimate user sees when one of them triggers.
Edition and hosting type
Banning addresses at the firewall requires control of the host, and that depends on how Odoo is hosted. Pricing lists Odoo.sh and on-premise hosting under the Custom plan, and the Enterprise source code is not publicly available, so confirm your edition, your hosting type and who controls the server. On Odoo.sh, ask Odoo whether host-level tools such as fail2ban can be installed before you plan the work. Community self-hosting leaves these choices to your team.
Odoo pricingClient address behind the proxy
When Nginx or another reverse proxy sits in front of Odoo, requests may arrive from the proxy's own address, so a ban would hit the proxy and cut off every user. Confirm that the proxy sets forwarded headers, that Odoo is configured to read them, and that only the proxy can supply those headers. Check that the address in the log line is the client's address, then test with a failed login from a second network before you rely on the jail.
On-premise docsQuestions teams ask before blocking Odoo brute force logins
What does blocking Odoo brute force logins cost, and what drives the effort?
The cost is the labor to configure and test the protection, and no supplied figure sets it. Effort rises with the number of entry points (the web login, the database manager, the API and any portal or website login), the complexity of the reverse proxy, how easily your team can reach the proxy and Odoo logs, and how much testing you need on a staging copy before production. Most of the work is one-time: writing the filter, the jail and the proxy rules, then verifying them. Recurring costs are tuning and reviewing bans as traffic changes. Ask any quote to list each entry point covered, the proxy and host work, the staging test plan, and whether retesting after Odoo or proxy upgrades is included.
How long does fail2ban setup for Odoo take?
Duration depends on the same factors that drive effort: how many login paths you protect, how many proxies and hosts sit in front of Odoo, how clean your log format is across Odoo versions and time zones, and how many test cycles your staging environment needs. A single host with one reverse proxy and a clear log path is the simplest case. Multi-server or containerized deployments take longer because logs may live in several places. Ask for a timeline tied to the written scope, with the staging test and production rollout as separate milestones.
Can our own team set up fail2ban for Odoo without a partner?
Yes, if the team has Linux administration skills, comfort with fail2ban filter and jail syntax, and access to the reverse proxy configuration and Odoo's log output. The work also needs someone who can read regular expressions and check them against real log lines, and someone who understands how the proxy forwards client addresses, because a wrong address means banning the proxy itself. A partner adds value mainly when the setup spans several entry points, when the team lacks time to test safely, or when the protection must be documented for an audit.
What do we need to give a provider for this work?
Plan to provide access to the reverse proxy configuration and its logs, the host running fail2ban with root or equivalent rights, and the Odoo configuration files. The provider also needs a staging copy of the database and server so that bans, cooldowns and CAPTCHA settings can be tested without locking out real users. You should also supply the list of login paths in use, the time zone your servers and logs use, and a named contact who can approve changes to the firewall and proxy. Confirm each item in writing before the work starts.
Does fail2ban replace two-factor authentication in Odoo?
No. Fail2ban limits repeated failed attempts by banning source addresses, so it slows automated guessing, but it does not verify who is logging in. An attacker using many addresses, or a valid password obtained through phishing, passes the ban logic. Two-factor authentication adds a second check tied to the user. Treat fail2ban as one layer alongside Odoo's own login cooldown and CAPTCHA settings, a strong password policy and two-factor authentication for accounts that need it.
What should a quote for this work list?
A written quote should name the entry points covered (web login, database manager, API, portal), the proxy and host changes, the filter and jail definitions, the Odoo login cooldown and CAPTCHA settings to be configured, and the timezone handling for log parsing. It should list the staging test plan, the production rollout steps, the handover documentation, and the retest after upgrades. Confirm whether ongoing tuning or monitoring is included, what is one-time and what recurs, and which items depend on access you supply. Fixed-scope quotes are agreed in writing before work starts.
How DeployOpen scopes and delivers Odoo login hardening
DeployOpen treats fail2ban for Odoo as one control inside a self-hosted deployment that we plan, build and document in your infrastructure. We start from how your Odoo login traffic reaches the server, then set the log path, filter, jail and proxy limits together so the ban logic matches what Odoo actually records. Engagements are fixed-scope, with the work agreed in writing before any change is made.
How we scope
- Map how logins reach Odoo, including any reverse proxy, load balancer or CDN that changes the client address fail2ban sees.
- Confirm the Odoo log destination, log level and server time zone, since timestamp offsets affect how the filter matches failures.
- Agree in writing which jails, ban durations, allowlisted networks and Odoo login settings are in scope and who approves them.
How we build
- Write and test the filter against sample failed-login lines from your own Odoo logs before enabling any ban action.
- Configure the jail, ban action and proxy rate limits as one design, so a block at the firewall and a limit at the proxy do not conflict.
- Set Odoo's own login cooldown and CAPTCHA options in the same change window, and record each value and its reason.
How we hand over
- Deliver the filter, jail and proxy configuration files with version-controlled change history and a short operations runbook.
- Document how to unban an address, check the jail status and recognize a log format change after an Odoo upgrade.
- Walk your administrators through a test failed-login sequence so they can confirm the ban works before go-live.
How we support
- Retest the login protections after each Odoo version change or proxy update, since log lines and client addresses can change.
- Ongoing support, upgrades and continuous testing are available as a retainer that covers the Odoo login path.
- Ask any support provider to confirm how they handle emergency unbans, change approval and logs kept for your security team.

