PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, September 2, 2022

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

 September 02, 2022     apache2.4, docker, drupal-8, nginx-reverse-proxy     No comments   

Issue

We have set up a reverse-proxy Nginx to redirect the requests to the right web service container.

Config Nginx reverse-proxy :

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;
    }
}

The website client_portal is hosted by another container using Apache as web server.

Config 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>

When I navigate to 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 I get a 404 error. I also tried this configuration (used in production) but the front page is not loading correctly (all css/ js files are broken) :

<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>

I have tried to switch apache to nginx and used the official drupal 8 configuration for nginx (https://www.nginx.com/resources/wiki/start/topics/recipes/drupal/) but I have the same problem. What is wrong in the configuration please ?


Solution

Finally, I found the error.

I had to use this configuration :

<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>

For Drupal the MultiViews option has to be disable :

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).

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



Answered By - V1v13n
Answer Checked By - David Marino (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing