如何在用作反向代理的另一个容器 Nginx 后面使用 Apache for Drupal 8 配置一个容器

How to configure a container with Apache for Drupal 8 behind another container Nginx used as a reverse proxy

我们已经设置了一个反向代理 Nginx 来将请求重定向到正确的 Web 服务容器。

配置 Nginx 反向代理:

server {
    listen 80 default_server;
    listen [::]:80 default_server;

    server_name weblab.mhf.mhc;
    client_max_body_size 200M;

    location /client_portal/ {
        resolver 127.0.0.11 ipv6=off;
        proxy_set_header X-Real-IP  $remote_addr;
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header Host $host;
        proxy_pass http://client_portal;
        access_log /var/log/nginx/client_portal.access.log;
        error_log /var/log/nginx/client_portal.error.log;
    }
}

网站 client_portal 由使用 Apache 作为 Web 服务器的另一个容器托管。

配置 Apache client_portal :

<VirtualHost *:80>
    ServerAdmin toto@toto.com
    ServerName weblab.mhf.mhc
    DocumentRoot /srv/www/
    ErrorLog ${APACHE_LOG_DIR}/client_portal.error.log
    CustomLog ${APACHE_LOG_DIR}/client_portal.access.log combined
    <Location "/client_portal">
        AllowOverride All
        Require all granted
    </Location>
</VirtualHost>

当我导航到 https://weblab.mhf.mhc/client_portal the front page is loading correctly with this config but the redirections are broken. If i go to https://weblab.mhf.mhc/client_portal/user/login 时,出现 404 错误。 我也试过这个配置(在生产中使用)但是首页没有正确加载(所有 css/ js 文件都坏了):

<VirtualHost *:80>
    ServerAdmin toto@toto.com
    ServerName weblab.mhf.mhc
    DocumentRoot /srv/www/
    ErrorLog ${APACHE_LOG_DIR}/client_portal.error.log
    CustomLog ${APACHE_LOG_DIR}/client_portal.access.log combined

    <Directory  /srv/www/client_portal>
        Options -Indexes +Includes +FollowSymLinks +MultiViews
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

我曾尝试将 apache 切换到 nginx,并为 nginx 使用了官方的 drupal 8 配置 (https://www.nginx.com/resources/wiki/start/topics/recipes/drupal/),但我遇到了同样的问题。请问配置有什么问题?

终于找到错误了

我不得不使用这个配置:

<VirtualHost *:80>
    ServerAdmin toto@toto.com
    ServerName weblab.mhf.mhc
    DocumentRoot /srv/www/
    ErrorLog ${APACHE_LOG_DIR}/client_portal.error.log
    CustomLog ${APACHE_LOG_DIR}/client_portal.access.log combined

    <Directory  /srv/www/client_portal>
        Options -Indexes +Includes +FollowSymLinks -MultiViews
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

对于 Drupal,必须禁用 MultiViews 选项:

If the Apache server has Options +MultiViews enabled by default, then the Apache >Virtualhost configuration should also contain Options -MultiViews (or have -MultiViews >added to the existing Options directive).

来源:https://www.drupal.org/docs/8/system-requirements/web-server