Skip to content
This page View Markdown Open in ChatGPT Open in Claude

Deployment

A website answers at /ssr/<apiPath>/<name>/ of the API Maker server, as soon as it is made : the path of its account (apiPath, as in the addresses of the APIs of the account), then its name — https://api.example.com/ssr/acme/shop/products for the website shop of the account acme. A name is unique in its account : two accounts may each have a shop. To show a website at the root of a domain of its own (https://shop.example.com/products), put a reverse proxy in front.

A domain of its own

  1. List the domain in site.config.ts :

    site.config.ts
    export default defineSite({ domains: ['shop.example.com', 'www.shop.example.com'] });
    

    For a request of such a host, the server writes the addresses of the website without /ssr/acme/shop : href="/products", asset('/app.css'), the redirects, the cookies (Path=/), the canonical addresses.

  2. Point the proxy at the website, keeping the host of the request.

server {
    listen 443 ssl;
    server_name shop.example.com;
    ssl_certificate     /etc/letsencrypt/live/shop.example.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/shop.example.com/privkey.pem;

    location / {
        proxy_pass http://127.0.0.1:48246/ssr/acme/shop/;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        client_max_body_size 20m;
    }
}
shop.example.com {
    rewrite * /ssr/acme/shop{uri}
    reverse_proxy 127.0.0.1:48246 {
        header_up Host {host}
    }
}
http:
  routers:
    shop:
      rule: Host(`shop.example.com`)
      service: api-maker
      middlewares: [shop-prefix]
      tls: { certResolver: letsencrypt }
  middlewares:
    shop-prefix:
      addPrefix: { prefix: /ssr/acme/shop }
  services:
    api-maker:
      loadBalancer:
        passHostHeader: true
        servers: [{ url: http://127.0.0.1:48246 }]

The settings view of a website in the panel writes these for its address.

HTTPS

Terminate TLS at the proxy and send X-Forwarded-Proto: https : the session cookie is Secure then (and __Host- at the root of a domain), and the answers carry Strict-Transport-Security. The origin a page knows (ctx.site.origin, the whole addresses of Open Graph and of feeds) is built from the host and that header.

The panel and the websites

Keep the admin panel on another host than the websites : admin.example.com for the panel, shop.example.com for the shop. A website then shares nothing with the panel in the browser. The panel runs on a port of its own by default (adminPanel.port).

Several servers

Every server of the installation answers every website : they read the websites from the database, and a save in the panel (or a pull of git) tells each to build the website again. Pages kept by the cache are kept by each server ; a save drops them everywhere.

The settings of the server

The websites share the server with the APIs. Their engines, threads and cache are set in the configuration of API Maker (ssr.*), and a website may ask for less or more for itself (limits of site.config.ts).

Setting Default What it is
ssr.threads the cores of the machine Threads which render pages, each with its engines
ssr.enginesPerThread 64 Websites a thread keeps loaded ; the one used longest ago goes
ssr.memoryMb 64 Memory of an engine : a render past it fails, the engine is made anew
ssr.cpuMs 2000 Time the code of one render may run : a loop which does not end is stopped
ssr.timeoutMs 30000 Time of one render in all, the waits for data included
ssr.cacheMb 64 Size of the pages kept by the cache, 0 for none

See API Maker configuration.