RoadRunner with NGINX

RoadRunner seamlessly integrates with various web servers like Nginx, providing a powerful backend solution for processing PHP requests.

Nginx configuration

FastCGI

RoadRunner can be configured to listen for FastCGI requests on a specific port. (Disabled by default.)

.rr.yaml
version: "3"

http:
  fcgi:
    address: tcp://0.0.0.0:9000

The FastCGI method allows Nginx to communicate directly with the RoadRunner server using the FastCGI protocol. This method is suitable when both Nginx and RoadRunner are running on the same machine.

docker/nginx/rr.conf
server {
   listen 80;
   listen [::]:80;
   server_name _;
   
   location / {
      fastcgi_pass 127.0.0.1:9000;
      include fastcgi_params;

      access_log off;
      error_log off;
   }
}

Consider using fastcgi_pass instead of proxy_pass: Using the fastcgi_pass directive might offer better performance in certain configurations.

Proxy

RoadRunner can be configured to listen for HTTP requests on a specific port.

Read more about configuring the HTTP server in the HTTP Plugin section.

The Proxy method involves configuring Nginx to act as a reverse proxy for RoadRunner. Nginx receives client requests and forwards them to RoadRunner for processing. This method is useful when both are running on separate machines or when additional load balancing or caching features are required.

WebSocket proxy

To enable WebSocket connections using an Nginx proxy, you need to configure the proxy accordingly.

This can be done by including the following configuration in the Nginx configuration file:

The location /connection block defines the path where WebSocket connections will be handled.

Docker

In this example, we will demonstrate how to use RoadRunner with Nginx in a Docker environment.

Dockerfile

RoadRunner configuration

Create a .rr.yaml configuration file to specify how RoadRunner should interact with your PHP application.

PHP Worker

Create a PHP worker to handle HTTP requests.

Here is a simple example:

Do not forget the composer.json file:

Read more about the RoadRunner PHP Worker in the PHP Workers section.

Docker Compose

To assemble and manage all components, create a docker-compose.yaml file that defines the RoadRunner and Nginx services, as well as their configurations.

Store one of the configuration files provided in the Nginx configuration section in the docker/nginx directory.

Last updated

Was this helpful?