dev-resources.site
for different kinds of informations.
How to Set Up Laravel in a Subfolder Using Traefik
Published at
1/3/2025
Categories
docker
laravel
traefik
php
Author
ferri
Author
5 person written this
ferri
open
Here’s how you can run Laravel in a subfolder with Traefik. Let’s consider this scenario:
- Traefik is already installed with entry points
http
andhttps
. - Laravel will be installed in the
/app
subfolder. - Traefik and Laravel will use an external network called
traefik
.
Edit docker-compose.yml
as following:
services:
app:
image: your-app-image
# ...the rest of the configuration
networks:
- traefik
labels:
- traefik.enable=true
- traefik.docker.network=traefik
- traefik.constraint-label=traefik
- traefik.http.middlewares.app-strip.stripprefix.prefixes=/app
# HTTP entrypoint
- traefik.http.routers.app-http.entrypoints=http
- traefik.http.routers.app-http.rule=Host(`your-app-domain.com`) && PathPrefix(`/app`)
- traefik.http.routers.app-http.middlewares=https-redirect,app-strip
# HTTPS entrypoint
- traefik.http.routers.app-https.entrypoints=https
- traefik.http.routers.app-https.rule=Host(`your-app-domain.com`) && PathPrefix(`/app`)
- traefik.http.routers.app-https.tls=true
- traefik.http.routers.app-https.middlewares=app-strip
networks:
traefik:
external: true
Edit .env
and set the subfolder in APP_URL
.
APP_URL=https://your-app-domain.com/app
# ...the rest of the configuration
Edit app/Http/Middleware/TrustProxies.php
and ensure that all proxies are allowed to let Laravel generate HTTPS URLs.
Always use URL helpers like url()
, route()
, etc., to generate full URLs, including the subfolder path.
That’s it! Now you can run your compose file with docker compose up -d
and access your Laravel application via the subfolder.
traefik Article's
30 articles in total
How to Set Up Laravel in a Subfolder Using Traefik
currently reading
Traefik using owned SSL certificate
read article
Traefik Cloudflare DNS Challenge
read article
Docker for Load Balancing: Scaling Applications Efficiently
read article
Comprehensive Guide to Setting Up Load Balancing with Traefik, Docker, Django, and React
read article
ForwardAuth with Traefik: Streamlining Security for Microservices
read article
Opening Pandora's Container - Gaining Host Access (Part 2)
read article
ForwardAuth with Traefik: Streamlining Security for Microservices
read article
Effortless Next.js Deployment with Docker, Traefik, and GitHub Actions: A Complete Hosted Solution
read article
Traefik Proxy Guide: Configuring public Domain Names for Docker Containers
read article
Setting Up a Multi-Purpose Server with Amazon EC2, Docker, and Traefik
read article
Traefik with docker compose
read article
Setting Up Traefik and mkcert for Local Development
read article
How to increase AWS ELB keep-alive timeout when deployed from Traefik
read article
Boost Your DevOps Workflow with Traefik
read article
Auto-route multiple web projects using Traefik
read article
My Github Actions workflow for deploying web projects
read article
Adding a new Ghost via docker-compose to your traefik setup
read article
Exposing public applications on AWS EKS with Traefik
read article
K3s Traefik Ingress - configured for your homelab!
read article
Traefik Proxy e Amazon ECS
read article
Random 1: Traefik blocks CORS by Default
read article
Instalando Zabbix Server com MySQL, Grafana e Traefik em Docker
read article
NGINX vs. Traefik vs. Istio — Unlocking the Secrets to Mastering Kubernetes Ingress
read article
Easy steps to install K3s with SSL certificate by traefik, cert manager and Let’s Encrypt
read article
Customizing error pages in Traefik v.2
read article
Redirect HTTP to HTTPS and WWW to Non-WWW with Traefik 3
read article
Deploying a Medusa + Minio + MeiliSearch stack with Docker and Traefik
read article
Централизованное логирование
read article
ECS Anywhere & Traefik Proxy with ECS Compose-X
read article
Featured ones: