Laravel Example 502 Bad Gateway

I’m trying to set up a Laravel website using caddy.
The website folder path is /root/takiacademy.
I tried to follow Laravel Example and changed what I thought I should change.
So, this is what my file looks like:

apidev.takiacademy.me, web.takiacademy.dev {
  root /root/takiacademy/public
  fastcgi / 127.0.0.1:8000 php
  rewrite {
    to {path} {path}/ /index.php?{query}
  }
}

And then I started php artisan serve which listens to port 8000.
But when I try to open the website in browser I get 502 bad gateway

Hi @Burawi_Ben_Ammar, welcome to the Caddy community.

php artisan serve doesn’t start a FastCGI listener; it starts a web server.

You’ll want to use proxy instead of fastcgi to connect to port 8000.

Keep in mind you’re deviating from the example significantly; by using php artisan serve and proxying to it, you’re abandoning Caddy’s fully fledged web server functionality in favour of proxying to PHP’s internal, single-threaded, development-oriented web server. In Laravel’s provided example, they’re using Caddy to serve the site files directly and using FPM for processing PHP files.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.