-
Notifications
You must be signed in to change notification settings - Fork 4
Nginx
Francois edited this page Jan 20, 2026
·
1 revision
Presentation : Nginx was launched in 2004 and is today the most widely used webserver. It relies on an async architecture, each request being split into smaller subtasks. Many processes can be launched, offering a bigger throughput than Apache.
For this ft_transcendence project, we leveraged following features:
- security : TLS encryption is handled
- unified entry points for our routes as a reverse proxy
- static file serving
- protocol management betwwen https and WebSockets
Tip
Use npx nginx -t inside the container to validate your configuration syntax before restarting the service.
- HTTP to HTTPS redirection using a 308 permanent redirect to preserve request method and body
server {
listen 80;
server_name localhost;
return 308 https://$host:4430$request_uri;
}-
Header sanitization : clearing internal
x-user-nameandx-user-idfrom incoming requests
-
alias and
rootdirectives
location /api/ {
proxy_http_version 1.1;
proxy_pass http://api-gateway:3000;
}-
worker_connectionsandepollto handle sufficient concurrent connections - the upstream blocks define keepalive pools to reduce latency created by establishing new TCP connections
-
proxy_read_timeoutandproxy_send_timeoutare adjusted to routes
| โ Do | โ Don't |
|---|---|
| Use TLS 1.2 or 1.3 for modern security standards. | Use SSLv3 or TLS 1.0/1.1 as they are deprecated and insecure. |
Clear internal headers like x-user-id to prevent header spoofing attacks. |
Trust client-provided headers for authentication details. |
| Enable Gzip compression for text, CSS, and JS to improve performance. | Enable HTTP/2 if it conflicts with WebSocket implementation. |
Use proxy_cookie_path to ensure cookies from sub-services are correctly sent by the browser. |
- |
| Type | Resource | Notes |
|---|---|---|
| ๐ | Official Nginx Documentation | Main reference for all directives. |
| ๐ก๏ธ | Mozilla SSL Config Generator | Best practices for TLS security. |
- Gateway Service - API Gateway & JWT validation
- Auth Service - Authentication & 2FA/TOTP
- AI Service - AI opponent
- API Documentation - OpenAPI/Swagger
- Fastify - Web framework
- Prisma - ORM
- WebSockets - Real-time communication
- Restful API - API standards
- React - UI library
- CSS - Styling
- Tailwind - CSS framework
- Accessibility - WCAG compliance
- TypeScript - Language
- Zod - Schema validation
- Nginx - Reverse proxy
- Logging and Error management - Observability
- OAuth 2.0 - Authentication flows
- Two-factor authentication - 2FA/TOTP
- Avalanche - Blockchain network
- Hardhat - Development framework
- Solidity - Smart contracts language
- Open Zeppelin - Security standards
- ESLint - Linting
- Vitest - Testing
- GitHub Actions - CI/CD
- Husky, Commit lints and git hooks - Git hooks
- ELK - Logging stack
๐ Page model