Caddy 2 Varnish Setup

1. Caddy version (caddy version): 2

2. How I run Caddy:

On my VPS

a. System environment:

CentOS 8

b. Command:

caddy reload

#### c. Service/unit/compose file:
<!-- If using Docker/systemd/Kubernetes/make etc. -->

#### d. My complete Caddyfile or JSON config:, {
root * /var/www/html/mysite
import /etc/caddy/caddy_security.conf
reverse_proxy localhost:6081
php_fastcgi unix//var/opt/remi/php74/run/php-fpm/www.sock
encode zstd gzip
header Strict-Transport-Security max-age=15552000
@static {
path *.ico *.css *.js *.gif *.jpg *.jpeg *.png *.svg *.woff *.woff2
header @static Cache-Control max-age=15552000
log { 
output file /var/log/caddy/access.log 
format single_field common_log
@secure {
path *.sql *.bak *.zip *.tgz *.tar.gz
respond @secure 404

### 3. The problem I'm having:
<!-- What are you trying to do, and what isn't working? Please describe the issue thoroughly enough so that anyone can reproduce the exact behavior you're seeing. Be as specific as possible. -->

Unable to make Varnish work with Caddy 2.

### 4. Error messages and/or full log output:
<!-- Please **DO NOT REDACT** any information except credentials. -->

Error too many redirects.

### 5. What I already tried:
<!-- Show us what effort you've put in to solving the problem. Be specific -- people are volunteering their time to help you! Low effort posts are not likely to get good answers! -->

    I am trying to make varnish work on Caddy 2. However, I am getting error too many redirects problem on browser. I also have tried adding on wp-config.php:

    define('FORCE_SSL_ADMIN', true);

    But the problem doesn't go off.

    For my WordPress its:

    reverse_proxy localhost:6081

    Then added:

    localhost:80 {
    root * /var/www/html/thatworkfast
    php_fastcgi unix//var/opt/remi/php74/run/php-fpm/www.sock


    backend default {
    #    .host = "";
        .host = "localhost";
        .port = "80";

### 6. Links to relevant resources:


Or, if somebody can just provide me link to tutorial of varnish setup on Caddy 2?

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