Help wanted for porting working NGINX config

1. Caddy version (caddy version):


2. How I run Caddy:

Via official docker image

a. System environment:

Ubuntu 20.04.1
Docker 20.10.7

b. Command:

c. Service/unit/compose file:

version: "3.7"

    image: caddy
    container_name: caddy
    hostname: caddy
    restart: unless-stopped
      - "80:80"
      - "443:443"
      - MY_DOMAIN
      - ./Caddyfile:/etc/caddy/Caddyfile:ro
      - ./data:/data
      - ./config:/config

      name: $DOCKER_MY_NETWORK

d. My complete Caddyfile or JSON config:

    # acme_ca

docker.{$MY_DOMAIN} {
    reverse_proxy portainer:9000

rss.{$MY_DOMAIN} {
    root * /var/www/ttrss
    php_fastcgi unix//var/run/php/php7.4-fpm.sock {
        index index.php

3. The problem I’m having:

I have an existing installation of a PHP app (Tiny Tiny RSS) at /var/www/ttrss . I was using using NGINX as my reverse proxy and the following config was working for me:

upstream php-handler {
    server unix:/var/run/php/php7.4-fpm.sock;

server {
    listen 80;
    listen [::]:80;
    return 301 https://$server_name:443$request_uri;

server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    root /var/www/ttrss;
    index index.php;

    include snippets/ssl-defaults.conf;

    error_log /var/log/nginx/ttrss.error.log;
    access_log /var/log/nginx/ttrss.access.log;

    location / {
        try_files $uri $uri/ /index.php;

    location ~ \.php$ {
        include fastcgi.conf; # don't use fastcgi_params
        fastcgi_pass php-handler;
        fastcgi_index index.php;

I am trying to port this to Caddy, and my attempt so far can be seen in the caddyfile above. However it doesn’t seem to work and I am getting a blank page when I visit the url.

4. Error messages and/or full log output:

I do not have any error message. I just see a blank page when I visit the url.

5. What I already tried:

I have tried to write a caddyfile which can be seen above. But it’s possible that it’s not a complete port of the working NGINX config.

Another possible reason for it not working that I can think of, is that Caddy doesn’t have enough permission. But I am not sure what user it runs as.

6. Links to relevant resources:

It looks like you’re just using the stock Caddy image. Caddy does not come with PHP installed. You need to run a php-fpm container alongside Caddy, and that container will actually run your PHP code.

It also doesn’t look like you’ve mounted your site as a volume in the Caddy container, so Caddy can’t see the files.

I recommend looking for guides on setting up nginx+php-fpm in Docker. It’s the same setup for as for Caddy, but there’s more guides for that out in the wild than for Caddy at the moment.

Sorry if it was not clear from my post, PHP is already installed in my system, but not as a docker container. I already have a working configuration of PHP and Tiny Tiny RSS and NGINX, all non-dockerized. What I am trying to do now is replace NGINX with dockerized Caddy. Is it not possible? Will it work if I install Caddy as a systemd service, via package manager instead of docker?

Well, either dockerize everything, or dockerize nothing. Going halfway will only make it more difficult.

You can install Caddy using our apt repo and run it as a systemd service. If you already have the rest of your environment set up outside of Docker, that’ll be easier.

Thanks. Installing Caddy as a systemd service worked for me.

1 Like

This topic was automatically closed after 30 days. New replies are no longer allowed.