Questions tagged [caddyfile]

The term Caddyfile describes a text file that changes how an instance of the Caddy web server works.

Definition:

The Caddyfile is the configuration file of the web server.

It is similar in purpose to httpd.conf or nginx.conf.

The Caddyfile file can be named anything, but by default, Caddy will look for a file called Caddyfile in the current directory.

Example Usage:

example.com {
    root /www/example.com
}

sub.example.com {
    root /www/sub.example.com
    gzip
    log ../access.log
}

Important Links:

148 questions
3
votes
1 answer

Configuring Caddy+PHP in Docker

I'm trying to serve a PHP app using Caddy, all Dockerized. Here's my Caddyfile: http://mydomain.test root * /app/public php_fastcgi localhost:9000 rewrite * /index.php?{query}&p={path} file_server my Dockerfile: FROM php:7.0-fpm COPY…
cb7
  • 493
  • 4
  • 10
3
votes
0 answers

Caddy reverse_proxy Not Working for Python Flask Server

I am trying to use Caddy as a reverse proxy for a Python/Flask/Gunicorn API server running on port 5000. When I visit http://myipaddress:5000 using my browser I see a response from my API server as expected. However, when I visit…
Nyxynyx
  • 61,411
  • 155
  • 482
  • 830
3
votes
0 answers

Caddy: Dynamically redirect www to non-www & vice-versa

1. Caddy version (caddy version): 2.0.0 2. How I run Caddy: I use Docker (docker-compose) to run Caddyserver. Here is the command of my caddy service: command: ["caddy", "run", "--config", "/etc/caddy/Caddyfile"] a. System environment: Docker…
Anwar Hussain
  • 450
  • 2
  • 12
3
votes
2 answers

Caddy rewrite and redir

I have a tricky case. I want to redirect always exept in few case. I want to see "toto.png" when i request www.myWebsite.com/toto.png but also when i request www.myWebsite.com/titi or www.myWebsite.com/TITI. In all other case i want to redirect on…
Artentica
  • 65
  • 1
  • 8
3
votes
0 answers

How to redirect in Caddyfile keeping some part of the path?

I want to redirect URLs like this /origin/something to this /destination/something. I tried to do it using redir, but I didn't be able to get just some part of the path by using a placeholder. Then I tried with rewrite in these ways: rewrite /origin…
3
votes
2 answers

How do I achieve Caddy auto-TLS via Let's Encrypt without DNS?

I'm sure this is a typical scenario, but I can't find the appropriate sequence of steps. I have a www.example.com server at (say) 1.1.1.1 running Apache. I am building a new server at 2.2.2.2 using Caddy. For testing, I put 2.2.2.2 www.example.com…
pinoyyid
  • 21,499
  • 14
  • 64
  • 115
3
votes
1 answer

How do I tell Caddy which sub domain to use

I am trying to use Caddy for the first time. I want to be able to serve several subdomains. Caddy requests SSL certificates from Let's Encrypt. I have managed to get this to work ok with only one domain name in the caddyfile. However, suppose I…
Rick-777
  • 9,714
  • 5
  • 34
  • 50
2
votes
1 answer

Caddy server tries to open port 80 instead if 8090

Here's my Caddyfile: localhost:8090 # log log/access.log # tls sec/cert.pem sec/key.pem Here's I'm trying to run a Golang app: % caddy run 2023/06/06 03:55:25.997 INFO using adjacent Caddyfile 2023/06/06 03:55:25.999 INFO admin admin…
2
votes
1 answer

Caddy2 - Routing with php_fastcgi and path

I'm running a Caddy server with php on localhost My server is running perfectly on the main path : http://x.x.x.x/index.php. This is my initial configuration : x.x.x.x:80 { root * /var/www/html php_fastcgi php:9000 …
B.T
  • 521
  • 1
  • 7
  • 26
2
votes
1 answer

Caddy: Rewrite path to URL parameter

I am currently using Caddy as a reverse proxy. rewrite / /index.html https://localhost/ --> https://localhost/index.html https://localhost/?p1=v1&p2=v2 --> https://localhost/index.html?p1=v1&p2=v2 Now I want to additionally change the path /static…
michaelT
  • 1,533
  • 12
  • 41
2
votes
1 answer

Return custom 404 response if caddy reverse_proxy returns 404

I'm using caddy for dynamic ssl. I am using the reverse_proxy header and now I want to return a custom 404 response when the reverse_proxy returns a 404. Is it possible? I looked at handle_erros directive but looks like it doesn't work with…
Reyansh Kharga
  • 356
  • 5
  • 18
2
votes
1 answer

How to configure caddy to deliver static file for specific url?

I have created a api platform project with the API Platform distribution. It comes with a caddy server with a configuration like this: { http_port {$CADDY_PORT} # Debug {$DEBUG} # HTTP/3 support servers { protocol { …
Lenny4
  • 1,215
  • 1
  • 14
  • 33
2
votes
0 answers

Laravel Sail + Caddy - local dev site not trusted

First time using Docker + Sail + Caddy. I copied the Caddy setup from here. I have a local Laravel dev project which uses 2x subdomains (sd1.project.local, sd2.project.local). Everything looks fine on sail up. I can see the certs created in the…
TheRealPapa
  • 4,393
  • 8
  • 71
  • 155
2
votes
1 answer

Caddy2: how to set MIME type and Content-disposition for a file extension?

What is the way to configure/override how certain MIME types are handled? For example, with the default configuration a python file (.py) is served with Content-disposition": attachment which opens a file save dialog rather than displaying inline…
ccpizza
  • 28,968
  • 18
  • 162
  • 169
2
votes
1 answer

Caddy file server browse not working when I root a specific directory

Here is my Caddyfile: aruiplex.com { encode gzip file_server /files/* { root /files browse } reverse_proxy /api/* localhost:7022 file_server { root /srv …
Aruix
  • 41
  • 1
  • 7
1
2
3
9 10