- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我试图在 Docker 中运行 Apache,在 https 的 Traefik 反向代理后面。一切正常,除了当我访问没有斜杠的文件夹 URL 时,Apache 将我重定向到非 https(即 https://www.example.com/folder -> http://www.example.com/folder/ )。这是 Apache mod_dir DirectorySlash 引起的,如 here 所述& here .解决方案是使用重写规则,它在 DirectorySlash 之前启动,如下所示:
# Redirect to HTTPS before Apache mod_dir DirectorySlash redirect to HTTP
RewriteCond %{HTTP:X-Forwarded-Proto} =https
RewriteCond %{LA-U:REQUEST_FILENAME} -d
RewriteRule ^/(.*[^/])$ https://%{HTTP_HOST}/$1/ [R=301,L,QSA]
labels:
- traefik.enable=true
- traefik.port=80
- traefik.frontend.rule=PathPrefix:/web #Apache is accessible under https://example.com/web/
- "traefik.frontend.headers.SSLProxyHeaders=X-Forwarded-Proto:https"
- "traefik.frontend.headers.SSLRedirect=true"
- "traefik.https.middlewares.testHeader.Headers.CustomRequestHeaders.X-Script-Name=test"
- traefik.frontend.headers.frameDeny=true
最佳答案
对于任何发现这个并想知道的人,我的问题是双重的:
1) X-Forwarded-* header 在浏览器中不可见。您可以使用 phpinfo() 或通过转储 $_SERVER 变量在服务器上查看它们:
2) 重定向不工作的原因(修复 DirectorySlash 问题)是因为除了上面列出的 RewriteRules 之外,你的 htaccess 必须包括 重写选项 AllowNoSlash .来自 Apache documentation :
By default, mod_rewrite will ignore URLs that map to a directory on disk but lack a trailing slash, in the expectation that the mod_dir module will issue the client with a redirect to the canonical URL with a trailing slash. [...] the AllowNoSlash option can be enabled to ensure that rewrite rules are no longer ignored. This option makes it possible to apply rewrite rules within .htaccess files that match the directory without a trailing slash, if so desired.
关于docker - Traefik (Docker) 没有设置 X-Forwarded-* header ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55679620/
我正在尝试使用两个域和使用 Let's Encrypt 生成的证书来设置 traefik 的 dockerized 版本。 我已经修改了 traefik.toml 看起来像这样: [acme] e
traefik.frontend.rule=Host:example.com 将对 example.com 的请求重定向到该后端。那么traefik.domain有什么用呢? 最佳答案 默认前端规则为
traefik.frontend.rule=Host:example.com 将对 example.com 的请求重定向到该后端。那么traefik.domain有什么用呢? 最佳答案 默认前端规则为
我使用 docker compose(运行 swarm 模式)进行了以下设置: mydomain.com --> ContainerA:8080 但我想要的是通过标签,为同一个容器指定以下内容: my
我正在尝试使用 Traefik 在我的 Docker Swarm 模式集群中部署代理多个应用程序。 我已经得到它以便它代理一个命名的主机,但我希望它代理一个命名的主机和路径,但我无法计算出我需要使用的
我绝对爱上了 Traefik。然而,作为初学者,我想念 Nginx 风格 nginx -t来验证配置文件。 我在 docker 容器中运行 traefik,每当我更新我的配置文件(*.toml 文件)
我决定将 traefik 的版本从 1.7.x 升级到 2.2.1。 所以我遵循了上述解决方案的指导方针(https://gist.github.com/fatihyildizhan/8f124039
我们使用 traefik 来反向代理我们的微服务环境,在 Kubernetes 的 staging 和 prod 上运行,并在本地使用 docker-compose。我们正在尝试将请求代理到特定微服务
如何为日志文件启用日志轮换,例如访问.log。 这是内置的吗? 文档只说“这允许日志由外部程序旋转和处理,例如 logrotate” 最佳答案 如果您正在运行 Traefik 在 docker 容器然
我需要像这样重写我的应用程序的 URL:https://router.vuejs.org/guide/essentials/history-mode.html#example-server-confi
我需要将 SSL 连接直接发送到后端,而不是在我的 Traefik 上解密。后端需要接收https请求。 我尝试了 traefik.frontend.passTLSCert=true 选项,但是当我访
使用 docker,我尝试使用 HTTPS 端口 443 设置 traefik 后端,因此 traefik 容器和应用程序容器(apache 2.4)之间的通信将被加密。 我收到了 Internal
我有一个容器('矩阵'),基于 https://github.com/silvio/docker-matrix (虽然这可能并不重要)。 它在端口 8448 和 3478(不是 80 或 443)上运
我是 Docker 和 Traefik 的新手,所以我决定和他们一起玩一下。我试着按照这个 digital ocean 教程:https://www.digitalocean.com/communit
我有一个“服务器”设置,在容器中运行多个服务,其中 traefik 工作得很好。我想为在单独计算机上运行的服务添加虚拟主机,以便我可以访问 hassio.domain.com 并转发到该服务器。有一次
我已经将 Traefik 设置为在 Docker Swarm 模式下工作。我已使用以下命令将 Portainer 部署到集群中: docker service create
我正在从 Nginx 迁移到 Traefik 作为 Docker Swarm 的反向代理。 目前,每个带有 Bearer Token 的请求都会被发送到身份验证服务(在 Swarm 中运行的微服务),
使用 docker 容器中的 Traefix 1.2.3 版,我设置了以下文件。 traefik: image: traefik command: --web --docker --docke
我正在考虑为我的网络项目 (Kestrel/.Net Core) 将 Apache 替换为 Traefik。阅读文档后,关于 Traefik,我还有一些不清楚的地方: 1/Traefik 是否自动处理
我提前为我对 Traefik 的新手理解道歉,但有没有办法重写“非 www”域 带有基于请求的变量 ? 我已经在谷歌上搜索了一个多小时,找不到答案。 这是我如何在 Apache 中执行此操作的示例。你
我是一名优秀的程序员,十分优秀!