Using Drupal 8 with Nginx as a reverse proxy in a subdirectory configuration

Our web server is currently running Drupal 8 on nginx + php-fpm. We are looking to implement a reverse proxy server to make the D8 website accessible at www.somedomain.com/drupal8

The nginx configuration is functioning correctly:

location /article_dev/ {
    proxy_buffers 32 32k;
    proxy_buffer_size 32k;
    proxy_pass http://192.168.158.148:80/;
    proxy_set_header    Host $host;
    proxy_set_header    X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header    X-Forwarded-Proto $scheme;
    proxy_set_header    X-Forwarded-By $server_addr:$server_port;
    proxy_set_header    X-Real-IP $remote_addr;
}

I have also configured the reverse proxy settings in settings.php. The issue arises when I visit externaldomain.com/article_dev/ and the D8 page loads, but without CSS and other resources, as the paths are set to externaldomain.com/path_to_resource instead of externaldomain.com/article_dev/path_to_resource

In previous versions of Drupal (6 and 7), it was possible to utilize the global $base_url for this purpose. However, with D8, the use of $base_url in settings.php has been deprecated for reasons outlined here

Unfortunately, this knowledge does not bring me closer to successfully proxying the second site as a subdirectory...

Any assistance on this matter would be greatly appreciated!

Regards, T

Answer №1

In my opinion, for it to function properly, you need to activate multi-site and include a specific line in your $sites array within sites.php. The modified code should resemble the following:

$sites = array(
    ..existing code..
    'externaldomain.com.path_to_resource.article_dev'  => '<site>',
);

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

php query the database for a specific string

I need help searching a database using variable positions. The variables are created in the code below: &numbers //= input from user &naar //= input from user $number = range($numbers + 1, $naar - 1); // defining range between inputs fore ...

Can PHP files be rewritten using fwrite without deleting PHP comments?

Within a PHP file, there are some comments included. <?php $test = array( 'LBL_TEXT' => 'text',//test comment 'LBL_FOO' => 'foo' ); I want to change the value of 'LBL_TEXT' (& ...

How to retrieve the complete file path of an image during the image upload process

I am having trouble uploading an image as it only takes the file name with extension, not the full path. <!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js">< ...

Can a script command be used to trigger a particular PHP function in a PHP file via a bash script?

The title of this question is pretty self-explanatory, but I'll provide some more details. There's a PHP file named hello-world.php and a bash script named testBash.sh in my setup. Inside hello-world.php, there are two methods: helloWorld() and ...

Struggling to troubleshoot my php form (email not being sent)

First off, I want to mention that PHP is not my strong suit, so please bear with me if I make any mistakes. UPDATE: I attempted to echo the variables as suggested by you all, but it seems I am unable to retrieve any values from them. UPDATE2: The "class ...

recording the results of a Node.js program in PHP using exec

I'm attempting to retrieve the output from my node.js script using PHP exec wrapped within an ajax call. I am able to make the call and receive some feedback, but I can't seem to capture the console.log output in the variable. This is how I exec ...

Automatically refresh the page after submitting

Being relatively new to PHP and still learning, I encountered a problem with my current project. I am in the process of creating a page where I can store my favorite websites using the GET method to send the Title, URL, and Logo of the website to the serve ...

Using PHP variables in HTML frameset URL for dynamic content passing

Looking for help to pass a PHP variable through a frameset URL. I've been trying different techniques without success so far. Can anyone provide some guidance? Here is an example of my code and what I have attempted: <?php $var = 2+3 ?> < ...

Sending arguments from JavaScript to PHP via ajax

I am facing a challenge where I need to send a JavaScript variable to a PHP function. While I was successful in doing this with hard-coded values, I'm struggling when it comes to using variables. Here's an example of what worked for me: <butt ...

Display a user's purchased items within their profile on a WordPress website

Operating an e-commerce site at , built on wordpress and woocommerce. Utilizing the Ultimate Member plugin for user registration and login purposes. Currently seeking a plugin or method to allow users to view their orders directly from their profile. ...

How to manage cookies for Mac users using PHP

I am trying to set a cookie for Mac using PHP. Below is my code: setcookie("COOKIETEST","1",time() +3600*24*365,"/",".testingdomain.com"); The code works fine on Chrome and Firefox, but I am facing issues with setting the cookie for Safari web browser, a ...

Check if a key exists in an array that contains sub-arrays using the function array_key_exists

I am encountering an issue with a function. My goal is to include all pages, but the problem is that not all pages are named like the parameter $_GET['page']. For example, if I call index.php?p=accueil, it should redirect to php/home.php. Anoth ...

Retrieval of each single row from a PHP-generated JSON dataset

This is quite challenging, especially for me. My goal here is to use Javascript to extract each value of every row in this JSON data: {"id":2,"url":"image.png","x":19,"y":10,"user_id":20} {"id":3,"url":"image.png","x":19,"y":10,"user_id":20} {"id":4,"url" ...

What is the most efficient way to send an array of email addresses to SendGrid using just one API request

Currently, I have a requirement to send 500 unique emails to various recipients. However, the current process involves making 500 separate API calls to SendGrid, which takes approximately 9-10 minutes to complete sending to all recipients. Is there an al ...

PHP and Ajax do not $_POST the selected option value in <select>

I have implemented a system with two dropdown menus, one of which utilizes AJAX to fetch data from the database and present partial results on the page. Despite successfully submitting other input text (machine_no), I am encountering difficulties in postin ...

Strip the whitespace from the elements of the string

At runtime, I have a string that I explode into separate elements (tags) inputted via a text field. The goal is to remove extra white spaces before and after the ,. Here is an example of the string: $str = "tags,more tags ,even more tags, great art, pai ...

Troubleshooting problems with Jquery qtip ajax

I am currently attempting to send the value of an input box (specifically an IMDb link) to my imdbgrabber.php page in order to retrieve information about that movie and display it in a qtip box. EDIT: You can view the issue here. Hover over the images to ...

Retrieve specific element from an object using array notation in PHP

Have you ever wondered why the array syntax for accessing an object's property works differently across various versions of PHP? I encountered an interesting issue while working with the Amazon PHP SDK. This line of code, which accesses an object&apo ...

Merging two distinct inquiries into a unified approach

I am facing an issue with combining two queries into one. Here are the original queries and my attempt at combining them: //first query: SELECT @rownum := @rownum +1 `index` , t.* FROM ipAll t, ( SELECT @rownum :=0 ) r //second query: SELECT DISTI ...

Is it possible to only show the div element in my AJAX request without displaying the entire page

Is it possible to only show a specific div in my ajax request without displaying the entire page? The entire page is loaded, but I only want to display one div and hide the header and footer. However, I still need the header to be present on the page. jQ ...