Vary response header passed through?

1. Caddy version:

2.6.2

2. How I installed, and run Caddy:

Using docker-compose

a. System environment:

Github actions.

c. Service/unit/compose file:

version: '3'
services:
  mongo:
    image: mongo:latest
    ports:
      - "27019:27017"
    networks:
      - internal

  squidex1:
    image: squidex-local
    environment:
      - URLS__BASEURL=http://localhost:8080
      - ASSETS__RESIZERURL=http://resizer
      - EVENTSTORE__MONGODB__CONFIGURATION=mongodb://mongo
      - EVENTSTORE__MONGODB__DATABASE=squidex1
      - GRAPHQL__CACHEDURATION=0
      - IDENTITY__ADMINCLIENTID=root
      - IDENTITY__ADMINCLIENTSECRET=xeLd6jFxqbXJrfmNLlO2j1apagGGGSyZJhFnIuHp4I0=
      - IDENTITY__MULTIPLEDOMAINS=true
      - RULES__RULESCACHEDURATION=00:00:00
      - SCRIPTING__TIMEOUTEXECUTION=00:00:10
      - SCRIPTING__TIMEOUTSCRIPT=00:00:10
      - STORE__MONGODB__CONFIGURATION=mongodb://mongo
      - STORE__MONGODB__DATABASE=squidex1
      - STORE__MONGODB__CONTENTDATABASE=squidex1_content
      - STORE__TYPE=MongoDB
      - TEMPLATES__LOCALURL=http://localhost:5000
      - ASPNETCORE_URLS=http://+:5000
    networks:
      - internal
    depends_on:
      - mongo

  squidex2:
    image: squidex-local
    environment:
      - URLS__BASEURL=http://localhost:8081/squidex/
      - URLS__BASEPATH=squidex/
      - ASSETS__RESIZERURL=http://resizer
      - EVENTSTORE__MONGODB__CONFIGURATION=mongodb://mongo
      - EVENTSTORE__MONGODB__DATABASE=squidex2
      - GRAPHQL__CACHEDURATION=0
      - IDENTITY__ADMINCLIENTID=root
      - IDENTITY__ADMINCLIENTSECRET=xeLd6jFxqbXJrfmNLlO2j1apagGGGSyZJhFnIuHp4I0=
      - IDENTITY__MULTIPLEDOMAINS=true
      - RULES__RULESCACHEDURATION=00:00:00
      - SCRIPTING__TIMEOUTEXECUTION=00:00:10
      - SCRIPTING__TIMEOUTSCRIPT=00:00:10
      - STORE__MONGODB__CONFIGURATION=mongodb://mongo
      - STORE__MONGODB__DATABASE=squidex2
      - STORE__MONGODB__CONTENTDATABASE=squidex2_content
      - STORE__TYPE=MongoDB
      - TEMPLATES__LOCALURL=http://localhost:5000
      - ASPNETCORE_URLS=http://+:5000
    networks:
      - internal
    depends_on:
      - mongo

  squidex3:
    image: squidex-local
    environment:
      - URLS__BASEURL=http://localhost:8082
      - ASSETS__RESIZERURL=http://resizer
      - CONTENTS__OPTIMIZEFORSELFHOSTING=true
      - EVENTSTORE__MONGODB__CONFIGURATION=mongodb://mongo
      - EVENTSTORE__MONGODB__DATABASE=squidex3
      - GRAPHQL__CACHEDURATION=0
      - IDENTITY__ADMINCLIENTID=root
      - IDENTITY__ADMINCLIENTSECRET=xeLd6jFxqbXJrfmNLlO2j1apagGGGSyZJhFnIuHp4I0=
      - IDENTITY__MULTIPLEDOMAINS=true
      - RULES__RULESCACHEDURATION=00:00:00
      - SCRIPTING__TIMEOUTEXECUTION=00:00:10
      - SCRIPTING__TIMEOUTSCRIPT=00:00:10
      - STORE__MONGODB__CONFIGURATION=mongodb://mongo
      - STORE__MONGODB__DATABASE=squidex3
      - STORE__MONGODB__CONTENTDATABASE=squidex3_content
      - STORE__TYPE=MongoDB
      - TEMPLATES__LOCALURL=http://localhost:5000
      - ASPNETCORE_URLS=http://+:5000
    networks:
      - internal
    depends_on:
      - mongo

  resizer:
    image: squidex/resizer:dev-40
    networks:
      - internal
    depends_on:
      - mongo

  webhookcatcher:
    image: tarampampam/webhook-tester
    command: serve --port 1026
    ports:
      - "1026:1026"
    networks:
      - internal

  squidex_proxy1:
    image: squidex/caddy-proxy
    ports:
      - "8080:8080"
    environment:
      - SITE_ADDRESS=http://localhost:8080
      - SITE_PATH=*
      - SITE_SERVER="squidex1:5000"
    depends_on:
      - squidex1
    networks:
      - internal
    restart: unless-stopped

  squidex_proxy2:
    image: squidex/caddy-proxy-path
    ports:
      - "8081:8081"
    environment:
      - SITE_ADDRESS=http://localhost:8081
      - SITE_PATH=/squidex/*
      - SITE_SERVER="squidex2:5000"
    depends_on:
      - squidex2
    networks:
      - internal
    restart: unless-stopped

  squidex_proxy3:
    image: squidex/caddy-proxy-path
    ports:
      - "8082:8082"
    environment:
      - SITE_ADDRESS=http://localhost:8082
      - SITE_PATH=*
      - SITE_SERVER="squidex3:5000"
    depends_on:
      - squidex2
    networks:
      - internal
    restart: unless-stopped
    
networks:
  internal:
    driver: bridge

d. My complete Caddy config:

{$SITE_ADDRESS}

reverse_proxy {$SITE_SERVER}
{$SITE_ADDRESS}

reverse_proxy {$SITE_PATH} {$SITE_SERVER}

3. The problem I’m having:

I am running a few tests for my headless CMS in github actions. I use several setups:

  1. Site is hosted under root path (caddyfile 1)
  2. Site is hosted under sub path (caddyfile 2)
  3. Another db setting (does not matter here)

In my tests I check whether some headers are configured correctly:

var rawClient = _.ClientManager.CreateHttpClient();

var response = await rawClient.PostAsJsonAsync($"/api/content/{_.AppName}/graphql", query);

Assert.Equal(new string[]
{
	"Auth-State",
	"X-Flatten",
	"X-Languages",
	"X-NoCleanup",
	"X-NoEnrichment",
	"X-NoResolveLanguages",
	"X-Resolve-Urls",
	"X-ResolveFlow",
	"X-Unpublished"
}, response.Headers.Vary.Order().ToArray());

The tests works fine under the root path, but under the sub path the headers are empty. Except the path I do not see any difference in my setup. Could there be a reason why the “Vary” header is omitted by caddy?

Please don’t omit any parts of the help topic template. It’s important that you completely fill it out, so that we have proper context of what’s going on with your setup.

What’s in your logs? Make some example requests with curl -v to show the behaviour you’re seeing.

I have no direct access to the logs yet. I have to invest a few hours to get improve the build flow to dig into that. I was hoping there would be a setting that I have missed.

What do you mean? You’re running Caddy as a Docker container, right? Use docker-compose logs to read your Caddy container’s logs.

I have had some issues in the past to run docker locally. So I thought I would run into this again. But this time it just worked.

But the issue is totally on my side:

The following line of code just generates the wrong URL:

var response = await rawClient.PostAsJsonAsync($"/api/content/{_.AppName}/graphql", query);

The base URL is http://localhost:8081/squidex but with /api/content/{_.AppName}/graphql it becomes

http://localhost:8081/api/content/{_.AppName}/graphql and not

http://localhost:8081/squidex/api/content/{_.AppName}/graphql what I need. Stupid me :frowning:

1 Like

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