【问题标题】:How to configure a container with Apache for Drupal 8 behind another container Nginx used as a reverse proxy如何在另一个用作反向代理的容器 Nginx 后面使用 Apache 为 Drupal 8 配置容器
【发布时间】:2018-12-20 16:54:45
【问题描述】:

我们已经设置了一个反向代理 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 客户端门户:

<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 时,首页使用此配置正确加载,但重定向被破坏。如果我转到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/) 但我遇到了同样的问题。请问配置有什么问题?

【问题讨论】:

    标签: docker drupal-8 apache2.4 nginx-reverse-proxy


    【解决方案1】:

    终于找到了错误。

    我不得不使用这个配置:

    <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 选项:

    如果 Apache 服务器默认启用了 Options +MultiViews,则 Apache >Virtualhost 配置还应包含 Options -MultiViews(或将 -MultiViews >添加到现有的 Options 指令中)。

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

    【讨论】:

      猜你喜欢
      • 2019-05-18
      • 2021-09-30
      • 1970-01-01
      • 1970-01-01
      • 2017-03-21
      • 1970-01-01
      • 1970-01-01
      • 2020-09-10
      • 2017-04-09
      相关资源
      最近更新 更多