laravelkubernetesnginxswoolelaravel-octane

When deploying a Laravel Octane app with Swoole on Kubernetes (or AWS ECS), is a separate Nginx container required alongside the Octane app?


In the context of Kubernetes (or AWS ECS), when deploying a Laravel Octane application using Swoole (or RoadRunner), is it essential to include a separate Nginx container (or any other web server) alongside the Octane app container?

Given that Laravel Octane utilizes Swoole (or RoadRunner) as a built-in web server, does the presence of Nginx remain necessary? Can the Octane app be directly exposed on port 80 to receive requests from a load balancer, such as the AWS Load Balancer, without needing an additional web server like Nginx?


Solution

  • If you are using an AWS loadbalancer as a reverse proxy it is generally not necessary to have an additional nginx container in front of swoole (maybe their loadbalancers are even running on nginx under the hood).

    Unlike PHP-FPM, Swoole has a fully fledged built in Http server that could theoretically even manage SSL itself.

    The only reason I can think of to use nginx in your setup is if you serve a lot of static files from your container since nginx just does that more efficiently than swoole. On the other hand, if you're on AWS I would instead recommend serving static files from an S3 bucket through Cloudfront anyways.