1. The problem I’m having:
I am running a Django website using gunicorn in a container. I installed Caddy on the (Ubuntu) host and made a reverse proxy to the container
This works for my website, and it looks nice, however I use django-bootstrap and I see it loads the css etc from a url. When I go to the Admin interface though, there is no styling and Firefox reports:
2. Error messages and/or full log output:
The resource from “http://e6b1.ts.net/static/admin/css/base.css” was blocked due to MIME type (“text/html”) mismatch (X-Content-Type-Options: nosniff).
admin
The resource from “http://e6b1.ts.net/static/admin/js/nav_sidebar.js” was blocked due to MIME type (“text/html”) mismatch (X-Content-Type-Options: nosniff).
admin
The resource from “http://e6b1.ts.net/static/admin/css/dark_mode.css” was blocked due to MIME type (“text/html”) mismatch (X-Content-Type-Options: nosniff).
admin
The resource from “http:/e6b1.ts.net/static/admin/css/nav_sidebar.css” was blocked due to MIME type (“text/html”) mismatch (X-Content-Type-Options: nosniff).
admin
The resource from “http:/e6b1.ts.net/static/admin/css/dashboard.css” was blocked due to MIME type (“text/html”) mismatch (X-Content-Type-Options: nosniff).
admin
The resource from “http://e6b1.ts.net/static/admin/js/theme.js” was blocked due to MIME type (“text/html”) mismatch (X-Content-Type-Options: nosniff).
admin
Loading failed for the <script> with source “http://e6b1.ts.net/static/admin/js/theme.js”. admin:9:43
The resource from “http://e6b1.ts.net/static/admin/css/responsive.css” was blocked due to MIME type (“text/html”) mismatch (X-Content-Type-Options: nosniff).
admin
The resource from “http://e6b1.ts.net/static/admin/css/nav_sidebar.css” was blocked due to MIME type (“text/html”) mismatch (X-Content-Type-Options: nosniff).
admin
The resource from “http://e6b1.ts.net/static/admin/css/dashboard.css” was blocked due to MIME type (“text/html”) mismatch (X-Content-Type-Options: nosniff).
admin
The resource from “http://e6b1.ts.net/static/admin/js/nav_sidebar.js” was blocked due to MIME type (“text/html”) mismatch (X-Content-Type-Options: nosniff).
3. Caddy version:
v2.10.0 h1:fonubSaQKF1YANl8TXqGcn4IbIRUDdfAkpcsfI/vX5U=
4. How I installed and ran Caddy:
sudo apt install caddy
a. System environment:
Ubuntu 24.04
Django runs in a podman container with gunicorn
b. Command:
sudo systemctl start caddy
c. Service/unit/compose file:
services:
rnaseqtracker:
build:
context: .
dockerfile: Containerfile
container_name: rnaseqtracker
ports:
- 127.0.0.1:8000:8000
volumes:
- ./db:/app/db
d. My complete Caddy config:
# The Caddyfile is an easy way to configure your Caddy web server.
#
# Unless the file starts with a global options block, the first
# uncommented line is always the address of your site.
#
# To use your own domain name (with automatic HTTPS), first make
# sure your domain's A/AAAA DNS records are properly pointed to
# this machine's public IP, then replace ":80" below with your
# domain name.
:80 {
# Set this path to your site's directory.
#root * /usr/share/caddy
# Enable the static file server.
#file_server
# Another common task is to set up a reverse proxy:
reverse_proxy localhost:8000
# Or serve a PHP site through php-fpm:
# php_fastcgi localhost:9000
}
# Refer to the Caddy docs for more information:
# https://caddyserver.com/docs/caddyfile
This is a relevant section of my Django config:
STATIC_URL = 'static/'
STATIC_ROOT = Path(BASE_DIR, STATIC_URL)
I have tried several things on the caddy side, but nothing seems to work. I do find the static folder in the root of my website inside the container, but perhaps caddy does not know how to reach it?