# Web Servers

> Architecture options for integrating Trident with Nginx or Apache as reverse proxy or edge cache.

Trident works with any web server. The two most common setups are placing a web server **in front of** Trident (reverse proxy mode) or placing Trident **in front of** a web server (edge cache mode).

## Architecture 1: Web Server in Front of Trident

The web server handles TLS termination and forwards requests to Trident, which caches responses from your backend application.

```
Client --HTTPS--> Nginx/Apache --HTTP--> Trident (:8120) --HTTP--> Backend (:8080)
```

**Use this when:**

- You already have Nginx or Apache managing TLS certificates (e.g. via Let's Encrypt / Certbot)
- You want to keep your existing web server configuration and add Trident as a caching layer
- You need the web server for features like rate limiting, access control, or serving static files directly

## Architecture 2: Trident in Front of Web Server

Trident sits at the edge and forwards cache misses to Nginx or Apache, which runs your application.

```
Client --HTTP--> Trident (:8120) --HTTP--> Nginx/Apache (:8080) --> App
```

**Use this when:**

- Your web server is tightly coupled with the application (e.g. Apache with `mod_php`)
- You want Trident to handle all incoming traffic and cache as much as possible
- You prefer a simpler setup without an extra reverse proxy layer

## Comparison

| | Web Server in Front | Trident in Front |
|---|---|---|
| TLS termination | Web server | External (load balancer, CDN) or Trident listener with `tls: true` |
| Static files | Can be served directly by web server | Cached by Trident |
| Complexity | Extra proxy hop | Simpler chain |
| Best for | Existing web server setups | New deployments, containerized apps |

## Next Steps

- [Nginx](https://docs.qoliber.com/docs/trident/web-servers/nginx) - Configuration examples for Nginx
- [Apache](https://docs.qoliber.com/docs/trident/web-servers/apache) - Configuration examples for Apache
