Why put a web application firewall in front of OpenEMR on Apache
A web application firewall in front of self-hosted OpenEMR gives you a control at the web server that sits between users, portal visitors and FHIR API clients and the PHP application itself. OpenEMR is GPL v3.0 open-source software, so your organization owns the deployment, the configuration and the evidence that it works. The Securing OpenEMR guide asks you to allow only HTTPS, consider opening only port 443, remove setup.php and other admin scripts after installation, and block direct web access to sites/*/documents. Those steps close the most obvious doors. A WAF adds a filter for malicious request patterns on the traffic that remains, but it is one layer among several and does not replace patching.
The work described here is a configuration and verification task in infrastructure you control: Apache modules, the ModSecurity engine, the OWASP Core Rule Set and rate limiting, all running on your own web servers or load balancers. Nobody outside your environment changes these settings, and the results live in your logs and change records. Confirm who on your side will own rule tuning, who reviews blocked requests, and who signs off on a change that affects clinical workflows.
The firewall does not remove the need to upgrade. OpenEMR 8.3.0 and 8.4.0 fixed security vulnerabilities in FHIR APIs, the patient portal, billing, the fax and SMS module and the fee sheet. Some of those flaws may be reachable through requests that a generic rule set does not recognize, so a rule can reduce exposure while you schedule the upgrade but cannot close the vulnerability. Treat the WAF as a way to buy time and reduce noise, and track each security release against your running version.
What each layer does on the Apache stack
Server token hiding controls how much Apache reveals about itself in response headers and error pages. The directives ServerTokens and ServerSignature shape that output, so a scanner sees less version detail when it fingerprints the host. This reduces reconnaissance noise but does not fix anything. A vulnerable OpenEMR release or PHP build behaves the same whether or not the banner says so, and version details are often recoverable from other responses.
- Protection given: Fewer version strings in the
Serverheader and default error pages, which makes automated fingerprinting slower and less precise. - What it cannot stop: Exploitation of a known flaw. Attackers can infer the stack from application paths, file layouts and behavior.
- Known cost: Very low. Mostly a support consideration, since troubleshooting tickets will show less version detail.
- Interaction to test: Confirm that the setting also covers any reverse proxy or load balancer in front of Apache, which may add its own headers.
- Operational note: Keep the real version in your own asset inventory so patch decisions do not depend on banners.
After changing these directives, request the site with a simple client and confirm the headers and an intentional 404 page match your expectations. Confirm exact directive behavior against the Apache release you run.
ModSecurity is the rule engine that inspects request and response content against a rule set. The OWASP Core Rule Set (CRS) provides generic detections for injection, cross-site scripting and similar patterns. Paranoia level 2 enables more rules than the default, which catches more attacks but also flags more legitimate traffic. In OpenEMR, that traffic includes clinical notes, free text fields, file uploads and FHIR payloads, so tuning is part of the work.
- Protection given: Pattern-based detection of common web attacks, including many injection and scripting attempts, before they reach PHP.
- What it cannot stop: Logic flaws in OpenEMR code, broken access control, or attacks that use encoding or structure the rules do not match. Rules also do not replace patching.
- Known cost: False positives on clinical text, rich-text editors, lab or imaging references, and API bodies. Blocked requests can interrupt charting or billing mid-task.
- Start in detection mode: Run the engine in logging mode first so you can see what would have been blocked before enforcing.
- Confirm versions: Check the ModSecurity and CRS versions your distribution packages against the rule set you intend to deploy.
Before enforcing, record the rule IDs that fire during clinical workflow testing and decide per rule whether to exclude, adjust or keep blocking. Verify this against the rule documentation for your chosen CRS release.
mod_evasive limits how many requests a single client can make to Apache within a short window, and it can temporarily block clients that exceed the threshold. It targets request floods and aggressive scripted probing, which pattern rules do not handle well. The risk is that many clients in a clinic share one source address behind NAT or a proxy, so thresholds set too low can lock out a whole site. Patient portal logins, FHIR clients and scheduled integrations also generate bursts that look like attacks.
- Protection given: Slows brute force and crawling activity and reduces the impact of simple request floods on Apache workers.
- What it cannot stop: Distributed attacks from many addresses, slow and low-rate abuse, or attacks that succeed in a single request.
- Known cost: Availability. Shared source addresses, load balancers and integration bursts can trigger blocks for legitimate users.
- Check source identity: Confirm whether Apache sees the real client address or the address of a proxy, since this decides who gets blocked.
- Allowlist deliberately: Exempt known interface engines and internal networks only after reviewing that they cannot be spoofed.
Test thresholds with realistic clinic traffic patterns, including morning login peaks, and confirm the module version and its directive names against your Apache distribution before deployment.
Configuration options and when each fits
This table compares the main configuration choices for putting ModSecurity and the OWASP Core Rule Set in front of OpenEMR on Apache, along with the rate limiting and engine alternatives. Read each row against your own clinical workflows, since the right setting depends on how much false-positive risk your staff can absorb and how quickly you can tune rules. Most teams should start in detection-only mode at a conservative paranoia level, then tighten once tuning is complete.
| Choice | Trade-off | When it fits |
|---|---|---|
| ModSecurity 2 versus 3 | Version 2 is older and tied to the Apache module model, while version 3 uses a separate library and connectors that vary in maturity. Confirm connector status before use, since some server integrations are marked experimental. | Pick the version your distribution packages and supports, and confirm the Apache connector status for that release before building on it. |
| CRS paranoia level 1 | Fewest rules enabled, so fewest false positives in clinical forms, but it catches less of the attack traffic that targets patient portal and FHIR endpoints. | Good first step for a new deployment where clinical staff are still testing workflows. |
| CRS paranoia level 2 | More rules enabled, so better coverage of common injection and cross-site scripting patterns, with more tuning work on free-text notes, rich text fields and uploads. | Common target for a production OpenEMR server once the test plan for clinical workflows has passed. |
| CRS paranoia levels 3 and 4 | Strictest coverage with the highest false-positive rate, since legitimate clinical text and encoded data often trip rules meant for attacks. | Usually reserved for specific endpoints after a long tuning period, not for the whole application. |
| Detection-only versus blocking mode | Detection-only logs matches without stopping requests, which shows false positives without disrupting clinicians. Blocking mode stops matched requests, which is what protects the application. | Run detection-only during testing and tuning, then move to blocking once logs show no legitimate clinical request is matched. |
| Per-path rule exclusions | Target a single rule for a specific path or parameter, such as a note field. This keeps protection in place elsewhere but requires careful documentation of each exclusion. | Best choice when one form or endpoint produces a known false positive. |
| Global rule disablement | Turning off a rule for the whole application removes protection everywhere that rule applies, and the reduced coverage is easy to overlook in later reviews. | Avoid unless a rule is shown to be unsuitable for the entire application and the decision is recorded. |
| mod_evasive thresholds versus upstream rate limits | mod_evasive limits per-client request rates on the web server itself. A load balancer or CDN can limit traffic before it reaches Apache, but clinical sites sharing one public address may be affected by shared limits. | Use upstream limits where the network is already managed. Set local thresholds only after testing with realistic clinical usage patterns and confirming limits in your environment. |
| Coraza as an alternative engine | Coraza is an open-source web application firewall library written in Go that runs ModSecurity SecLang rules and the OWASP Core Rule Set, licensed under Apache-2.0. It has integrations for Caddy, HAProxy, Traefik and Nginx, but not a native Apache module, so confirm the Apache deployment path before choosing it. | Consider it when your proxy layer is one of the supported integrations or when you want a Go-based engine. Confirm the integration status first, since some are experimental. |
How to set up and verify the firewall in front of OpenEMR
This sequence moves OpenEMR's public surface from an inventory of routes to a tuned, blocking web application firewall, with a check at each stage so the team can show what is exposed, what is blocked and what legitimate clinical traffic still gets through.
Inventory every public route
Before touching Apache, list each path reachable from outside the network: the login page, patient portal, FHIR and OAuth2 endpoints, document upload handlers, the REST API and any module endpoints. Include the paths your integrations and patient portal users actually call. Record the expected method, typical request size and whether the route accepts file uploads, because these decide which rules will need exclusions later. Done when the list is reviewed by the clinical application owner and the security lead, and each route has an owner. Confirm the full route set against your installed version and enabled modules, since the list will differ between deployments.
Confirm only HTTPS on port 443 is exposed
The Securing OpenEMR guide says to allow only HTTPS and to consider opening only port 443. Check the perimeter firewall, load balancer and host firewall rules against that guidance, and confirm that plain HTTP redirects or is closed. From an external host, run a port scan limited to the public address and confirm that only 443 answers. Check that the redirect from port 80, if one exists, does not serve any application content. Done when the external scan output matches the approved list and is saved with the change record.
Remove setup and admin scripts
Remove setup.php and other administrative scripts after installation, as the Securing OpenEMR guide recommends, and confirm that sites/*/documents is blocked from direct web access. Verify with requests to known paths from outside the network: setup.php and similar admin scripts should return a 404 or 403 rather than an application page, and a direct request for a stored document should be refused. Keep an offline copy of any script you need for future upgrades so the removal does not block your maintenance process. Done when each path returns the expected status code and the results are recorded.
Install ModSecurity and the OWASP CRS
Install the ModSecurity engine for Apache along with the OWASP Core Rule Set, then load the rules in the order your distribution's documentation specifies. Set the CRS paranoia level to 2 in the configuration, as this topic plans. Confirm the modules load by checking the Apache error log at startup and by running a configuration syntax test before any reload. Because OpenEMR changes between versions, record the ModSecurity and CRS versions you install so later upgrades can be tested against a known baseline. Done when the configuration test passes and the modules appear in the loaded module list.
Start in detection-only mode and collect logs
Set the engine to detection-only so rules log matches without blocking requests. Exercise every route from the inventory with normal clinical actions: sign in, open a chart, save a encounter, upload a document, call the FHIR endpoints and complete a portal session. Then review the audit log for rule IDs that fired on these legitimate requests. Done when each core workflow has been run end to end and the team can point to log entries for each rule that matched during testing, with the request path and the rule ID recorded.
Tune exclusions per route
For each false positive found in the logs, decide whether to add a narrow exclusion scoped to the specific route, parameter and rule ID, or to leave the rule active. Avoid turning off rule groups globally, because that removes protection from every route. Keep each exclusion in version control with a note explaining the clinical workflow it supports. Re-run the test scripts after each change and confirm the rule no longer fires on the legitimate request while still firing on a crafted malicious payload used in a test. Done when both checks pass for every tuned rule.
Switch to blocking mode
Once the detection-only logs show no unexplained matches on legitimate traffic, switch the engine to blocking. Repeat the full clinical test set and the malicious test payloads against the blocking configuration. Legitimate requests should return normal responses, and test payloads should return a block status with a matching rule entry in the log. Keep detection-only as a documented rollback option for the first release cycle. Done when both sets of results are recorded and signed off by the application owner.
Add mod_evasive and hide server tokens
Install mod_evasive to apply request rate limits, and tune its thresholds against the request rate your practice and integrations generate, so that busy clinic hours and scheduled integrations are not blocked. Hide server tokens and the server signature in the Apache configuration, then check response headers from an external host to confirm that the version banner no longer appears. Verify rate limiting with a controlled burst from a test host and confirm the block is logged. Done when the header check and the rate-limit test both produce the expected results and the configuration is committed to version control.
Testing clinical workflows for false positives before blocking
Run the clinical workflows in detect-only mode before any CRS rule is allowed to block, because OpenEMR sends the kind of input that generic CRS rules were written to distrust. Free-text encounter notes can contain angle brackets, quotation marks and SQL-like fragments such as dosing expressions or lab ranges. Billing entries carry codes and punctuation, document uploads send multipart bodies with binary content, and patient portal messages carry arbitrary prose. Any of these can match a SQL injection or cross-site scripting rule at paranoia level 2 even though the request is entirely legitimate. The test plan should therefore start from the workflows, not from the rule list.
Build the test plan from test patients and de-identified data, never from live patient records. Use a staging copy of the OpenEMR instance with synthetic patients, and walk through scheduling, encounter notes and forms, e-prescribing or orders where your practice uses them, lab or document upload, portal login and messaging, report generation, and FHIR calls from any SMART app you have approved. Each step should be scripted so it can be repeated after every CRS update or rule change. Confirm with your own team which modules are enabled, because a scripted path that skips an enabled module leaves a gap.
For each blocked request, record the rule ID, the matched argument, the URI, the user role and the timestamp, then decide whether it is a true positive. A true positive is an attack payload or a request that a legitimate workflow should never produce. A false positive is a valid clinical entry that the rule misread. Document each accepted exclusion with the narrowest scope that works, such as a single rule ID limited to one path or parameter, plus a named owner, the reason, the evidence and a review date. Set the review date to coincide with each CRS upgrade, since rule IDs and content change between releases. Never exclude a rule globally to silence one form.
Agree the exit criteria before switching to blocking mode: every scripted workflow completes, every remaining block is explained, and the portal and FHIR paths are covered by the same tests. Ask your security team to confirm which logs the WAF writes and where they go, because the staging evidence is only useful if production logs are kept in the same form. The test results also feed the audit trail that compliance reviewers will ask about.
Security and operational considerations for a WAF in front of OpenEMR
A web application firewall reduces exposure while OpenEMR is patched, but it adds rules, logs and change work that your team must own. The cards below cover the decisions that keep the WAF from becoming a source of new risk or a source of clinic outages.
A WAF compensates, it does not patch
ModSecurity with the OWASP Core Rule Set filters common request patterns, but it cannot see every flaw in portal, FHIR and module code. Security releases such as 8.3.0 and 8.4.0 fixed vulnerabilities in the FHIR API, patient portal, billing, fax and SMS module and fee sheet, and those fixes still need to be applied. Treat the WAF as a layer that buys time between a disclosure and a patch, and keep a documented emergency patch window alongside it. Confirm with your own tests which vulnerable paths the rules actually block.
- Latest release supplied
- 8.4.1
Exclusions can open gaps
When a rule blocks a legitimate clinical form, the quick fix is a rule exclusion for that parameter, path or request body. Each exclusion removes inspection from that input, so a broad exclusion can let an attacker reach the same weakness through the same field. Record every exclusion with its reason, the rule ID, the exact scope and the person who approved it. Review the list at each rule update and remove exclusions that no longer match a working workflow.
Logs hold PHI-adjacent data
WAF audit logs record request URIs, query strings and sometimes bodies, which can include patient identifiers, note fragments or search terms. Decide who may read these logs, where they are stored and how long they are kept before the first rule goes live. Restrict access to the security group, encrypt the log store and align retention with your HIPAA risk analysis and any state rules you must follow. Confirm the logging format you enable before you ship logs to a central platform.
Rule and CRS updates need a change process
The Core Rule Set and your local rule files change over time, and a new release can flag workflows that worked the day before. Stage updates in a test copy of OpenEMR that uses realistic but synthetic records, run your clinical workflow scripts against it and compare blocked requests with the last baseline. Keep the rule set under version control so you can roll back a single change. Assign an owner who signs off each update and records the test results.
Rate limits can block shared clinic addresses
mod_evasive limits how many requests a single client can make in a short window. Many clinics, hospitals and telehealth sites reach the internet through one NAT address, so the limit may treat a whole building as one abusive client. Before enabling it, ask network staff which public addresses your users share, set thresholds from measured peak use, and define a path for staff to clear a temporary block. Test with several concurrent users on the same address.
Documenting the Security Rule safeguards
The WAF supports technical safeguards, but the HIPAA Security Rule places audit controls, integrity protections and transmission security on the covered entity or business associate to document. The rule does not require a certification, so your own evidence matters. Write down how WAF logs feed audit controls, how you detect tampering with rule files, and how TLS settings protect data in transit. Use the HIPAA Security Rule text and the assessment guidance from NIST SP 800-66 Rev. 2 to map each control to the evidence you keep.
NIST SP 800-66 Rev. 2Questions buyers ask before hiring help with an OpenEMR WAF
What drives the cost of an OpenEMR WAF engagement, and can it be fixed-scope?
Yes. Most DeployOpen engagements are fixed-scope, with scope, deliverables and timelines agreed in writing before work starts, and a quote follows from that written scope. DeployOpen does not publish a price list. The main cost drivers are the number of hostnames and routes that sit behind Apache, how many clinical workflows need to be tested (scheduling, encounters, billing, the patient portal, document upload), whether you run Docker, multisite or a single host, and how much false-positive tuning the first pass produces. Ask any quote to list the environments covered, the workflows in the test plan, the number of retest rounds, and whether ongoing rule maintenance is included or quoted separately as a retainer.
How long does ModSecurity tuning for OpenEMR usually take?
No researched figure is available for duration, so ask for a timeline in the quote rather than assuming one. Tuning time tends to scale with three things: the number of routes and endpoints Apache serves for OpenEMR, the number of clinical workflows that must be exercised end to end, and the number of false positives the Core Rule Set raises on those workflows. Each false positive needs to be traced in the audit log, judged as legitimate or malicious, and fixed with a narrow exclusion rather than a broad disable. Ask the provider how many tuning cycles are assumed, how many workflows are in scope, and what happens if the first clinical test pass surfaces more blocks than planned.
What does the work need from our team before and during tuning?
Four things are needed, and a quote should name who provides each. First, test accounts for each role that uses OpenEMR, such as front desk, clinician, billing and patient portal users, with no real patient data in them where possible. Second, clinical staff time to walk through their own workflows during testing, because automated scans cannot judge whether a blocked form submission was a real clinical action. Third, change windows for enabling rules in enforcement mode after they have run in detection mode. Fourth, read access to Apache error and ModSecurity audit logs, plus a named contact who can approve exclusions. Confirm your own retention and access policies for those logs before granting access.
Can a small IT team tune a WAF for OpenEMR without outside help?
A small team can do it if it has someone comfortable with Apache configuration, ModSecurity SecLang rule syntax, reading audit logs, and the OpenEMR application itself. The work is less about writing rules and more about deciding, for each blocked request, whether it is an attack or a clinical workflow, then recording that decision. Plan for time to run the clinical test pass, which usually needs staff who know the workflows. Check whether your team can keep rule exclusions documented across OpenEMR upgrades, since a new release can change the requests the application sends. Many teams split the work: internal staff run the clinical walkthroughs, and an outside team handles rule configuration and review.
Does a web application firewall make OpenEMR HIPAA compliant or certified?
No. A WAF is one technical control, and it does not make a system HIPAA compliant or certified. HHS states that no Security Rule standard requires an entity to certify compliance, and there is no HIPAA certification. The HIPAA Security Rule (45 CFR Part 164 Subpart C) requires covered entities and business associates to perform a risk analysis and put administrative, physical and technical safeguards in place, based on that analysis. A WAF can support the technical safeguards and the risk analysis, but it needs to sit alongside access control, audit logging, encryption and staff policies. Penalties are assessed per violation, so document how the WAF fits into your risk analysis and review it with your compliance lead.
What happens after go-live, including rule updates and OpenEMR upgrades?
Go-live starts the maintenance cycle rather than ending the project. Three activities recur: updating the OWASP Core Rule Set and the ModSecurity or Coraza engine, reviewing new audit log entries for false positives, and retesting clinical workflows after each OpenEMR upgrade, because a new release can change request patterns or add endpoints. Security releases, such as the 8.3.0 and 8.4.0 fixes to FHIR, portal, billing and fee sheet code, may also require new exclusions or tighter rules on specific paths. Ask whether the quote covers these as a retainer, how upgrade retesting is scoped, and who approves rule changes in production. Confirm the Coraza connector status for your server before choosing an engine, since some integrations are marked experimental.
Is the Coraza WAF a drop-in replacement for ModSecurity with Apache?
Not necessarily, so confirm it before planning. Coraza is an open-source web application firewall library written in Go that runs ModSecurity SecLang rules, including the OWASP Core Rule Set, under the Apache-2.0 license. Its documented integrations cover Caddy, HAProxy, Traefik and Nginx, and some server integrations are marked experimental. An Apache deployment with the native ModSecurity module is the more direct path, while a Coraza-based setup would need a supported connector for your server design. Ask the provider which engine they recommend for your Apache version, how rule compatibility is verified, and what support exists if the connector changes.
How a request flows through Apache, ModSecurity and OpenEMR
The diagram starts with a clinician or patient portal user on the internet side of the trust boundary. TLS terminates at Apache, where ServerTokens and mod_evasive limit what is revealed and how fast a client can hit the server. ModSecurity then inspects the request against the OWASP Core Rule Set, with exclusions applied for known clinical false positives, before the request reaches the OpenEMR PHP application. Check that blocked and allowed requests both reach the audit log.
Request path from the internet through Apache and ModSecurity into OpenEMR, with logging.
How DeployOpen scopes the hardening work
The scope for this work is agreed in writing before any configuration changes are made. The first step is an inventory of what the Apache front end actually serves: the OpenEMR virtual hosts, the paths and routes that reach the application, which are exposed to the internet and which only to the clinic network, the patient portal and FHIR API paths, any reverse proxy or load balancer in front of Apache, and the PHP version and database platform in use. Many false positives come from routes nobody listed, such as a fax or SMS callback or an integration endpoint that posts large payloads, so this inventory decides where rule exclusions will be needed. Confirm with your team which OpenEMR version and deployment method (package, Docker or Kubernetes) you run, because that changes where the Apache configuration lives.
The written deliverables usually include the Apache and ModSecurity configuration as applied to your environment, the OWASP Core Rule Set version and paranoia level with the reasons for each setting, an exclusion register that records every rule removed or narrowed, the mod_evasive thresholds and their basis, test evidence from the clinical workflow tests, and a runbook covering log review, rule updates and how to roll back a change. The exclusion register is the document most worth insisting on, because it is the record an auditor or a future administrator will need to understand why a control is weaker in one place than the default. Ask for the format and owner of each deliverable in the quote.
A hardening change is not finished until it is retested. After the configuration is applied and the exclusions are settled, the clinical workflows are run again, and the same request paths are probed to confirm that blocking still happens where intended. Any later change to OpenEMR, the Core Rule Set or the Apache configuration starts the same loop. DeployOpen can also test the deployed setup as a separate security testing engagement, which gives an independent view of whether the web application firewall can be bypassed. Keeping that testing separate from the configuration work lets the people who wrote the rules be checked by someone else.
How DeployOpen delivers OpenEMR hardening
DeployOpen plans, builds, tests and documents the Apache and ModSecurity layer in front of your OpenEMR installation, inside infrastructure you control. Each engagement starts with a written scope that names the hosts, virtual hosts, rule exclusions and clinical workflows to be covered, so your clinical, security and IT teams agree on what is changed before any work begins.
How we scope
- Inventory your Apache version, OpenEMR release, PHP version and the hosts or virtual hosts that serve OpenEMR and the patient portal.
- Agree the ModSecurity and OWASP Core Rule Set version, paranoia level and mod_evasive thresholds in the written scope before work starts.
- List the clinical workflows, such as scheduling, charting, billing and portal forms, that must be covered by the false positive test plan.
How we build
- Apply server token hiding and ModSecurity configuration to a staging copy of your OpenEMR server, then promote it through your change process.
- Tune rule exclusions per endpoint and record each exception with its reason, so the exclusion list can be reviewed later.
- Run a false positive test pass across the clinical workflows in the scope, with test data only, and fix blocked legitimate requests before go-live.
How we hand over
- Deliver the Apache and ModSecurity configuration files, rule exclusion register and the version pins used for the build.
- Document the audit log location, how to read blocked events and the steps to add or remove an exclusion safely.
- Provide a test record showing each clinical workflow tested, the result and the retest performed after fixes.
How we support
- Engagements are fixed-scope, with scope, deliverables and timelines agreed in writing before work starts.
- Ongoing support, rule set updates and continuous testing are available as a retainer, which you can ask us to quote alongside the initial scope.
- Ask for a quote that separates the one-time build from any recurring retainer, so you can compare it with your own team's effort.

