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.)
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.
Remember to adjust the configuration examples according to your specific environment and requirements. If RoadRunner and Nginx are running in separate Docker containers, utilize the container DNS names (e.g., roadrunner:9000
) instead of IP addresses in the Nginx configuration.
Proxy
RoadRunner can be configured to listen for HTTP requests on a specific port.
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.
Remember to adjust the configuration examples according to your specific environment and requirements. If RoadRunner and Nginx are running in separate Docker containers, utilize the container DNS names (e.g., roadrunner:8080
) instead of IP addresses in the Nginx configuration.
WebSocket proxy
To enable WebSocket connections using Nginx proxy, you need to configure the proxy accordingly.
This can be done by including the following configuration in the Nginx configuration file:
http://127.0.0.1:8000
is the default address for the Centrifugo WebSocket server and /connection/websocket
is the default path for Bidirectional WebSocket connections.
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
Consider using the direct version in production. The latest
image tag might be used in development environments only.
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 the HTTP requests.
Here is a simple example:
And do not forget about the composer.json
file:
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
Last updated
Was this helpful?