嗨,我在Docker中将Traefik设置为反向代理。 在服务器尝试将其重定向到某个URL之前,它可以正常工作。 即。 我有这样的设置服务:
docker-compose.yml
version: "3.4"
services:
php:
image: 192.168.1.17/rab/php:latest
networks:
- backend
- proxy
labels:
- "traefik.enable=true"
- "traefik.backend=php"
- "traefik.frontend.rule=Host:192.168.1.27"
- "traefik.docker.network=proxy"
- "traefik.port=9000"
container_name: php
apache:
image: 192.168.1.17/rab/apache:latest
networks:
- proxy
links:
- php
labels:
- "traefik.enable=true"
- "traefik.backend=apache"
- "traefik.frontend.rule=Host:192.168.1.27; PathPrefixStrip:/rab;"
- "traefik.docker.network=proxy"
- "traefik.port=80"
- "traefik.frontend.entryPoints=http"
- "traefik.frontend.headers.SSLRedirect=false"
container_name: apache
networks:
backend:
proxy:
external:
name: traefik_proxy
因此,如果我输入http://192.168.1.27/rab/login.php,则它有效,并显示登录页面。
但是,当我成功登录后,它会尝试将我重定向到http://192.168.1.27/index.php而不是http://192.168.1.27/rab/index.php,这不起作用
apache的配置是:
ServerName localhost
LoadModule deflate_module /usr/local/apache2/modules/mod_deflate.so
LoadModule proxy_module /usr/local/apache2/modules/mod_proxy.so
LoadModule proxy_fcgi_module /usr/local/apache2/modules/mod_proxy_fcgi.so
<VirtualHost *:80>
# Proxy .php requests to port 9000 of the php-fpm container
ProxyPassMatch ^(.*\.php(.*)?)$ fcgi://php:9000/var/www/html/$1
DocumentRoot /var/www/html/
<Directory /var/www/html/>
DirectoryIndex login.php
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
如何解决此问题? 请帮助
谢谢