1. The problem I’m having:
I have a Laravel application. Static files for the admin panel are located in the /public folder. All static files are accessible via /, but I need them to be accessible via /admin and to add the /admin prefix to all admin panel pages, while requests still go to /. I’ve written a Caddyfile, which works in principle, but I don’t like its appearance because it uses an additional port, and the configuration file itself is very large. Also, there is an issue with the /exchangers path because there is a similar path on Nuxt. If I reload the page on the /exchangers page from the Nuxt side, it redirects to /admin/exchangers, which is incorrect behavior. /admin/exchangers and just /exchangers should be isolated from each other. How can I improve it and make more clear?
2. Caddy version: v2.7.6
3. How I installed and ran Caddy:
a. System environment: MacOS 14.4.1, arm64, Docker 24.0.7
b. My complete Caddy config:
:80 {
log
encode gzip
handle /admin/* {
uri strip_prefix /admin
reverse_proxy http://caddy:81
}
handle /login* {
reverse_proxy http://caddy:81
}
handle /logout* {
reverse_proxy http://caddy:81
}
handle /es/* {
reverse_proxy /es http://golang:8080
}
handle /ws/* {
reverse_proxy /ws/ http://rust:8081
}
handle /phantom/* {
reverse_proxy http://phantom:8083
}
handle /exchangers* {
reverse_proxy http://node:3000
}
handle / {
reverse_proxy http://node:3000
}
handle {
reverse_proxy http://node:3000
}
@except {
not path /admin*
not path /sitemap
not path /login*
not path /logout*
not path /contacts*
not path /icons*
not path /_*
not path /imgs*
not path /fonts*
not path /favicon*
not path /content/*
not path /ws/*
not path /es/*
not path /phantom/*
not path /
}
redir /es /es/
redir /phantom /phantom/
redir /ws /ws/
redir /admin /admin/
redir @except /admin{uri}
}
:81 {
root * /var/www/public
php_fastcgi php-fpm:9000
file_server
}