Nginx roles
- Web server — serves static files (CSS, JS, images) directly, without PHP
- Reverse proxy — accepts client requests and forwards them to PHP-FPM, Node.js, or another backend
- Load balancer — distributes traffic across multiple servers
- SSL termination — handles HTTPS so the backend can use plain HTTP internally
PHP + Nginx
Nginx cannot execute PHP itself. It forwards .php requests to PHP-FPM via the FastCGI protocol (fastcgi_pass). PHP-FPM processes the request and returns an HTML response.