Skip to content

Nginx

These complete configurations require a valid Trident Core licence at /etc/trident/license.key, readable by the service user. The explicit license.path below selects that file; mounting a licence without configuring its path does not activate caching. A successful --check validates the configuration, not the entitlement. Verify licensed runtime status and a cacheable MISS followed by HIT with identical complete bodies.

Architecture 1: Nginx in Front of Trident

Nginx handles TLS and forwards all requests to Trident. Trident caches responses from your backend.

Client ──HTTPS──▸ Nginx (:443) ──HTTP──▸ Trident (:8120) ──HTTP──▸ Backend (:8080)

Nginx Configuration

upstream trident {
    server 127.0.0.1:8120;
    keepalive 64;
}

server {
    listen 443 ssl http2;
    server_name example.com;

    ssl_certificate     /etc/letsencrypt/live/example.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;

    location / {
        proxy_pass http://trident;

        proxy_set_header Host              example.com:443;
        proxy_set_header X-Forwarded-Host  example.com:443;
        proxy_set_header X-Real-IP         $remote_addr;
        proxy_set_header X-Forwarded-For   $remote_addr;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header Forwarded "";
        proxy_set_header X-Forwarded-Port "";
        proxy_set_header X-Scheme "";
        proxy_set_header X-Forwarded-Ssl "";
        proxy_set_header X-Forwarded-Scheme "";
        proxy_set_header X-Url-Scheme "";
        proxy_set_header X-Forwarded-Protocol "";
        proxy_set_header CloudFront-Forwarded-Proto "";
        proxy_set_header Front-End-Https "";
        proxy_set_header X-Forwarded-Server "";


        proxy_http_version 1.1;
        proxy_set_header Connection "";
    }
}

server {
    listen 80;
    server_name example.com;
    return 301 https://$host$request_uri;
}

Trident Configuration

{
  "license": {
    "path": "/etc/trident/license.key"
  },
  "server": {
    "listeners": [
      {
        "address": "127.0.0.1:8120"
      }
    ],
    "preserve_host": true
  },
  "backends": [
    {
      "name": "origin",
      "host": "127.0.0.1",
      "port": 8080
    }
  ],
  "security": {
    "trusted_proxies": [
      "127.0.0.1/32"
    ]
  },
  "cache": {
    "poisoning": {
      "known_hosts": [
        "example.com",
        "example.com:443"
      ]
    }
  },
  "admin": {
    "address": "127.0.0.1:6085",
    "auth_token": "${TRIDENT_ADMIN_TOKEN}"
  }
}

Bind to localhost

When Nginx sits in front, bind Trident to 127.0.0.1:8120 instead of 0.0.0.0:8120 so it only accepts connections from Nginx.

Keepalive connections

The keepalive 64 directive and Connection "" header enable persistent connections between Nginx and Trident, reducing connection overhead.

Architecture 2: Trident in Front of Nginx

Trident is the entry point. Cache misses are forwarded to Nginx, which serves the application.

Client ──HTTP──▸ Trident (:8120) ──HTTP──▸ Nginx (:8080) ──▸ App

Trident Configuration

{
  "license": {
    "path": "/etc/trident/license.key"
  },
  "server": {
    "listeners": [
      {
        "address": "0.0.0.0:8120"
      }
    ],
    "preserve_host": true
  },
  "backends": [
    {
      "name": "origin",
      "host": "127.0.0.1",
      "port": 8080
    }
  ],
  "security": {
    "trusted_proxies": [
      "127.0.0.1/32"
    ]
  },
  "cache": {
    "poisoning": {
      "known_hosts": [
        "example.com",
        "example.com:443"
      ]
    }
  },
  "admin": {
    "address": "127.0.0.1:6085",
    "auth_token": "${TRIDENT_ADMIN_TOKEN}"
  }
}

Nginx Configuration

Configure Nginx to serve the application on port 8080:

server {
    listen 8080;
    server_name example.com;

    root /var/www/html;
    index index.php index.html;

    location / {
        try_files $uri $uri/ /index.php?$args;
    }

    location ~ \.php$ {
        fastcgi_pass unix:/run/php/php-fpm.sock;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }
}

Forwarding trust and administration

The TLS example is a single-authority virtual host. Replace every literal example.com:443 and server_name/ServerName with the externally served authority and port. The edge sets authoritative Host, scheme and client IP, removes forwarding aliases, and does not append attacker-provided chains. Configure only the edge's actual immediate address in Trident's security.trusted_proxies. Bind Trident and administration to an appropriate private interface; loopback is appropriate when both processes share a host.

The Trident JSON examples require TRIDENT_ADMIN_TOKEN in the service environment. Verify both the file and environment with the actual candidate's --check command before starting or reloading the service.

Health checks

On the configured admin listener, GET /admin/health reports process health and GET /admin/ready reports backend readiness. These health routes are unauthenticated; keep administration private. The public proxy's /health is an application/origin route, not an implicit Trident admin health check.

Cache invalidation

Send a supported authenticated admin request directly over the private admin network, for example POST /admin/purge/url with JSON {"url":"/products/example","host":"example.com:443","scheme":"https","mode":"hard"} and Authorization: Bearer <operator-token>. Replace the authority and scheme with the exact values used for the cached site. A generic /purge route is not the current endpoint. Keep the admin listener and operator token restricted; do not expose an unauthenticated purge proxy on the public virtual host.