O'Reilly logo

Instant Nginx Starter by Martin Fjordvald

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Quick start – Interacting with backends

Obviously, this virtual host is quite boring, all it does is serve a static file, and while that is certainly useful, it's practically never all we want to do. Something more interesting would be to serve PHP requests, perhaps even for a framework with a front controller pattern and search engine friendly URLs.

Step 1 – A quick backend communication example

Communicating with a backend is done by passing the request to the backend if certain conditions are met. For example, in the following server block:

server { listen 80; server_name example.com; root /var/www/website; index index.php; location / { try_files $uri $uri/ /index.php; } location ~ \.php$ { include fastcgi.conf; fastcgi_pass 127.0.0.1:9000; } ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required