Deprecated: imwpcache\f884414bce24ee67f\f73723ec7b1919fa5::__construct(): Implicitly marking parameter $YECBGYFECGEAFWHA as nullable is deprecated, the explicit nullable type must be used instead in /www/wwwroot/www.chuangxiangniao.com/wp-content/plugins/imwpcache-dist/build/f884414bce24ee67ff73723ec7b1919fa5.php on line 2

Deprecated: imwpcache\f884414bce24ee67f\f73723ec7b1919fa5::__construct(): Implicitly marking parameter $BBWFDDBHHYHDXXAB as nullable is deprecated, the explicit nullable type must be used instead in /www/wwwroot/www.chuangxiangniao.com/wp-content/plugins/imwpcache-dist/build/f884414bce24ee67ff73723ec7b1919fa5.php on line 2
如何使用 Traefik 在子文件夹中设置 Laravel_创想鸟

如何使用 Traefik 在子文件夹中设置 Laravel

如何使用 traefik 在子文件夹中设置 laravel

本文介绍如何在 Traefik 反向代理下,将 Laravel 应用部署到子文件夹中。 假设:Traefik 已安装并配置了 HTTP 和 HTTPS 入口点,Laravel 应用部署在 /app 子文件夹,Traefik 和 Laravel 使用名为 traefik 的外部网络。

修改 docker-compose.yml 文件如下:

services:  app:    image: your-app-image  # 替换为你的应用镜像    # ... 其他配置 ...    networks:      - traefik    labels:      - traefik.enable=true      - traefik.docker.network=traefik      - traefik.constraint-label=traefik      - traefik.http.middlewares.app-strip.stripprefix.prefixes=/app      - 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      - 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-stripnetworks:  traefik:    external: true

修改 .env 文件,在 APP_URL 中设置子文件夹路径:

APP_URL=https://your-app-domain.com/app# ... 其他配置 ...

修改 app/http/middleware/trustproxies.php,确保允许所有代理,以便 Laravel 正确生成 HTTPS URL。

务必使用 Laravel 的 URL 辅助函数 (如 url(), route() 等) 生成完整的 URL,包含子文件夹路径。

最后,使用 docker compose up -d 命令启动应用。 通过 your-app-domain.com/app 访问你的 Laravel 应用。

以上就是如何使用 Traefik 在子文件夹中设置 Laravel的详细内容,更多请关注创想鸟其它相关文章!

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 chuangxiangniao@163.com 举报,一经查实,本站将立刻删除。
发布者:程序猿,转转请注明出处:https://www.chuangxiangniao.com/p/1252284.html

赞 (0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2025年12月9日 23:53:12
PHP OOP 部分静态属性、方法以及 this 与 self
下一篇 2025年12月9日 23:53:32

相关推荐

发表回复

登录后才能评论
关注微信