Skip to content

odoo: per-instance LAN and internet exposure - #39

Merged
andrewthomaslee merged 1 commit into
mainfrom
odoo-expose
Nov 12, 2026
Merged

andrewthomaslee merged 1 commit into
mainfrom
odoo-expose

Conversation

@andrewthomaslee

Copy link
Copy Markdown
Member

Summary

Each Odoo instance stays local (https://<name>.odoo.localhost) and can add LAN and/or internet exposure, independently of the others:

 hostSpec.services.odoo = {
   enable = true;
+  lan = {                                  # shared by LAN-exposed instances
+    domain = "odoo.<host>.home.arpa";      # default; RFC 8375
+    addresses = [ ... ];                   # nginx listens here (values flake)
+    interfaces = [ ... ];                  # firewall 80/443 only here
+    allowedClients = [ ... ];              # nginx allow-list, else 403
+  };
+  acme.email = ...;                        # only with expose.public
   instances = {
-    demo = {};
+    demo.expose.lan = true;                # + https://demo.odoo.<host>.home.arpa
+    shop.expose.public = {                 # + https://erp.example.com, Let's Encrypt
+      enable = true;
+      domain = "erp.example.com";
+    };
     scratch = {};                          # local only
   };
 };
listener                 serves                                  certificate
127.0.0.1/::1 :443       <name>.odoo.localhost (every instance)   local CA
lan.addresses :443       <name>.<lan.domain> (expose.lan)        local CA (constraints + SANs now include lan.domain)
                         <lan.domain>: index, hosts lines, CA    (http://<lan.domain>/ca.crt for new clients)
0.0.0.0/[::] :443        <domain> (expose.public)                Let's Encrypt, HTTP-01
any other name / bare IP -> TLS handshake refused (catch-all default servers)
  • odoo-hosts: the hosts-file lines a LAN client (Windows laptop) needs.
  • Public hardening: /web/database/* 404, /web/login rate limit (429), HSTS, web.base.url frozen at the public URL.
  • Fix (also affects odoo: 0..n local instances with odoo-reset and odoo-purge #38 as merged): nginx got the TLS key via LoadCredential; systemctl reload nginx runs nginx -t as the nginx user, which cannot read credentials, so every reload (deploys, ACME renewals) failed and kept old certificates. The key is now a root:nginx 0440 clan var.
  • ip_nonlocal_bind while LAN-exposed: nginx starts before DHCP assigns the LAN address (beelink is on NetworkManager).
  • Docs: new page odoo-access.md (Windows hosts file + CA import, macOS/Linux, removal, internet checklist), cross-links from odoo.md, README.

Evidence

  • Before: instances local only; systemctl reload nginx failed (cannot load certificate key "/run/credentials/nginx.service/odoo-tls.key": Permission denied), first seen when pebble issued a cert and nginx kept serving the placeholder.
    After: all on euc-hel-0, sandboxed, exit 0:
vm-test odoo --remote          exit 0  (+ "nginx reloads" regression subtest)
vm-test odoo-reset --remote    exit 0
vm-test odoo-firefox --remote  exit 0
vm-test odoo-lan --remote      exit 0  client pastes odoo-hosts lines, downloads ca.crt over HTTP, uses
                                       demo + blank (login, demo data, websocket, index); local-only instance
                                       unreachable by any name; Odoo ports closed; stranger -> 403; CA rejects
                                       a cert for evil.example.com; nginx starts with the LAN address missing
vm-test odoo-public --remote   exit 0  pebble issues over HTTP-01, nginx reloads onto it; internet client logs in;
                                       web.base.url frozen; 404 database manager; HSTS; 429 on login burst;
                                       local-only instance unreachable
fmt; check                     exit 0  (eval fixture exposes instances to LAN and internet)

Merge Danger

Door: two-way

Additive options; nothing is exposed unless an instance asks. On machines that enable the module, odoo-local-ca and odoo-tls regenerate once (validation changed: CA constraints and SANs now include lan.domain), so clan vars generate <machine> before deploy; Firefox on the machine picks up the new CA via policy, LAN clients import it.

Blast Radius: beelink

Only beelink enables Odoo. Merge order: this PR, then home #44 (bumps modules, beelink exposes demo and blank to the home LAN, not the internet).

🤖 Generated with Claude Code

Each instance can now be reached beyond the machine itself, chosen per
instance: expose.lan serves https://<name>.odoo.<host>.home.arpa on the
LAN addresses (firewall on lan.interfaces, nginx allow-list
lan.allowedClients) with the local CA, whose name constraints and
certificate now also cover the LAN domain; clients get hosts-file lines
from odoo-hosts and the CA from http://<lan domain>/ca.crt. *.localhost
cannot work from other machines (browsers keep it local).
expose.public serves a real domain with a Let's Encrypt certificate
(HTTP-01), database manager 404, login rate limit, HSTS and a frozen
web.base.url. Catch-all servers refuse every other name.

Also fixes nginx reloads: the TLS key came in as a systemd credential,
which `nginx -t` on reload (run as nginx) cannot read, so every reload
(deploy, ACME renewal) failed and kept old certificates. The key is now
a root:nginx 0440 clan var. ip_nonlocal_bind lets nginx start before
DHCP assigns the LAN address.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@andrewthomaslee
andrewthomaslee enabled auto-merge (squash) November 12, 2026 18:19
@andrewthomaslee
andrewthomaslee merged commit fafe73c into main Nov 12, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant