I’m having a lot of trouble to setup Caddy for Laravel 5. My goal is to be able to log on the server, run curl localhost and get my website’s html as a response. The goal later is just to have a domain name that will redirect to this server.
The website is inside a Docker container, that links the port 80 inside to the port 80 outside.
I checked the configuration proposed in the Caddy’s Github, however I didn’t understand how I should use things such as FastCGI. I ended up removing them because it caused issues (ie, 502 - bad gateway, or simply a 404)
Here is my Caddyfile:
0.0.0.0:80 {
root /var/www/html/my-project/public
tls off
rewrite {
to {path} {path}/ /index.php?{query}
}
}
I removed tls because the server already handles the HTTPS, so no need to ask for two certificates. However, with this configuration, I get “404 Not Found” without understanding what’s wrong.
Hello, thanks for your reply, and I apologize for the time it took to answer. I also tried your command, but how should I adapt it to a Dockerfile?
For now, I just run “caddy”, with the Caddyfile in the “my-project” directory (that does exist, is chown as www-data:www-data and has a chmod 777 on it). This “status 200 /” seems to make everything work, but is there a way to adapt it in the Caddyfile configuration?
It’s not there to make anything work, it’s just to explain how I tested it to demonstrate that it wasn’t an issue with your 0.0.0.0 hostname, it was an issue with finding a file to serve.
If you’re requesting /, Caddy will try to serve an index. If there’s no index file in the web root, it’s going to find nothing to serve, and it’ll issue a 404 instead.