# In Docker how can I add a static file server to an existing setup?

**URL:** <https://community.traefik.io/t/in-docker-how-can-i-add-a-static-file-server-to-an-existing-setup/11996>\
**Category:** Traefik v2\
**Tags:** file, docker\
**Created:** [October 6, 2021, 12:37am UTC](https://community.traefik.io/t/in-docker-how-can-i-add-a-static-file-server-to-an-existing-setup/11996 "2021-10-06T00:37:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ultrabob](https://avatars.discourse-cdn.com/v4/letter/u/96bed5/32.png) [@ultrabob](https://community.traefik.io/u/ultrabob)\
**Post date:** [October 6, 2021, 12:37am UTC](https://community.traefik.io/t/in-docker-how-can-i-add-a-static-file-server-to-an-existing-setup/11996/1 "2021-10-06T00:37:28Z")

</div>

I have a working (gunicorn, uvicorn, fastapi) setup with TLS provided by Let's Encrypt. I now want to add nginx or caddy to be a file server. It should listen on a couple of paths /static /videos and serve files requested on those paths.

So let's say the domain is [service.example.com](http://service.example.com). app-http is redirecting to app-https and listening for all paths on that domain

I've added an nginx container listening on the same domain with label

```auto

- "traefik.frontend.rule=Host(`japanese-joinery.ultrabob.com`) && PathPrefix(`/static/`, `/videos/`, `/screencaps/`)"

```

Nothing seems to get routed to the new container. I tried adding an inverted PathPrefix rule to the app-https service

```auto

- "traefik.frontend.rule=Host(`japanese-joinery.ultrabob.com`) && !PathPrefix(`/static/`, `/videos/`, `/screencaps/`)"

```

but I see a message in the logs

> level=error msg="error while parsing rule !PathPrefix(`/static/`, `/videos/`, `/screencaps/`): ! is not supported" entryPointName=http routerName=app-http@docker

I also wonder if this new service will be able to seamlessly use the certificate that is being procured for app-https or if I will need some config to make that happen.

I'm sorry for a bit of a broad question, I'm not sure how to simplify my setup to get to the core of things without either removing the TLS part altogether or do a new dns setup so I can test locally.

---

<div class="post-metadata">

**Author:** ![cakiwi](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/cakiwi/32/3205_2.png) [@cakiwi](https://community.traefik.io/u/cakiwi)\
**Post date:** [October 12, 2021, 4:57pm UTC](https://community.traefik.io/t/in-docker-how-can-i-add-a-static-file-server-to-an-existing-setup/11996/2 "2021-10-12T16:57:08Z")

</div>

> [@ultrabob](#):
>
> `- "traefik.frontend.rule=Host(`japanese-joinery.ultrabob.com`) && PathPrefix(`/static/`, `/videos/`, `/screencaps/`)"`

Looks fine.

> [@ultrabob](#):
>
> I also wonder if this new service will be able to seamlessly use the certificate that is being procured for app-https or if I will need some config to make that happen.

If it is the same as your existing working domain it will be matched in the certificate store and used.

> [@ultrabob](#):
>
> I'm sorry for a bit of a broad question, I'm not sure how to simplify my setup to get to the core of things without either removing the TLS part altogether or do a new dns setup so I can test locally.

I run without a certificates resolver, ignore certificate errors and use curl's `--resolve` flag:

> **docker-compose.yaml**
>
> ```yaml
> version: "3.8"
> 
> services:
> traefik:
> image: "traefik:v2.5"
> command:
> - --entrypoints.web.address=:80
> - --entrypoints.web.http.redirections.entrypoint.to=websecure
> - --entrypoints.web.http.redirections.entrypoint.permanent=true
> - --entrypoints.websecure.address=:443
> - --entrypoints.websecure.http.tls=true
> - --providers.docker=true
> - --providers.docker.exposedbydefault=false
> - --accesslog
> - --accesslog.format=json
> - --api
> - --log.level=WARNING
> - --log.format=json
> labels:
> traefik.enable: "true"
> traefik.http.routers.api.rule: Host(`traefik.localhost`)
> traefik.http.routers.api.service: api@internal
> ports:
> - published: 80
> target: 80
> - published: 443
> target: 443
> volumes:
> - "/var/run/docker.sock:/var/run/docker.sock:ro"
> 
> whoami:
> image: traefik/whoami
> labels:
> - "traefik.enable=true"
> - "traefik.http.routers.w.rule=Host(`japanese-joinery.ultrabob.com`) && PathPrefix(`/static/`,`/videos/`,`/screencaps/`)"
> 
> ```

```shell
curl -k --resolve japanese-joinery.ultrabob.com:443:127.0.0.1 https://japanese-joinery.ultrabob.com/screencaps/
Hostname: e8e6d87109fe
IP: 127.0.0.1
IP: 172.29.0.3
RemoteAddr: 172.29.0.2:59262
GET /screencaps/ HTTP/1.1
Host: japanese-joinery.ultrabob.com
User-Agent: curl/7.68.0
Accept: */*
Accept-Encoding: gzip
X-Forwarded-For: 172.29.0.1
X-Forwarded-Host: japanese-joinery.ultrabob.com
X-Forwarded-Port: 443
X-Forwarded-Proto: https
X-Forwarded-Server: cb79a8b13fb5
X-Real-Ip: 172.29.0.1

```

---

<div class="post-metadata">

**Author:** ![ultrabob](https://avatars.discourse-cdn.com/v4/letter/u/96bed5/32.png) [@ultrabob](https://community.traefik.io/u/ultrabob)\
**Post date:** [October 13, 2021, 12:57am UTC](https://community.traefik.io/t/in-docker-how-can-i-add-a-static-file-server-to-an-existing-setup/11996/3 "2021-10-13T00:57:39Z")

</div>

Thank you, that curl tip is really helpful. I think my problem must not have been with the rule but something else in the configuration. I did finally get it working.
