1. The problem I’m having:
I have multiple apps and I only have 1 DNS. To separate the apps, I add prefix in the URI, e.g. www.domain.test/app-1
, www.domain.test/app-2
, and so on. So I preferred to use handle
or handle_path
directives in my configurations. The Problem:
Only my laravel application always ends-up to 404 Not Found.
2. Error messages and/or full log output:

3. Caddy version:
v2.7.4
4. How I installed and ran Caddy:
a. System environment:
OS: Ubuntu 22.04.3 LTS 22.04 Jammy
Laravel: v9
b. My complete Caddy config:
sub.domain.test {
encode zstd gzip
import static
import security
handle_path /alias-laravel-app* {
root * /var/www/html/laravel-app/public
php_fastcgi unix//var/run/php/php8.1-fpm.sock
}
root * /var/www/html/
php_fastcgi unix//var/run/php/php7.4-fpm.sock
file_server
}
5. Links to relevant resources:
You’ll need to configure your routes (in web.php
probably) to be aware of /alias-laravel-app
as a base. You can wrap all your routes like this:
Route::prefix('alias-laravel-app')->group(function () {
// Your routes here
});
See this article:
Have you ever tried to reverse proxy an app into its own little subfolder of your domain name?
Makes things neat, doesn’t it? Using example.com/foo/ for one app, example.com/bar/ for another. If you’re coming here from one of the selfhosted communities, you might be thinking along the lines of example.com/sonarr/, example.com/radarr/ etc.
Chances are, you’ve tried some configuration along these lines:
example.com {
redir /sonarr /sonarr/
handle_path /sonarr/* {
reverse_proxy localhost…
Ultimately the key is that your upstream app needs to be aware of being run within a subpath.
It worked, Thanks for the idea.
1 Like
system
(system)
Closed
November 5, 2023, 8:26am
4
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.