简体   繁体   中英

Docker + reverse-proxy(nginx) + subdirectory as root + wordpress(apache) + multisite

Note: Translate from portuguese to english on google translate, sorry...

I'm trying to put a wordpress website online being that the root of wordpress is already in a subdirectory (eg: webplace.example.br/subdirectory/ <--root-wordpress), but every time I set up the multisite and try using them, it starts to give problems. I'm using a container with nginx:alpine as a reverse proxy, for another container wordpress:php7.2 on the same host, I'm using this setting in nginx:

Note2: not wordpress I'm just trying to put a base online, I'm not going to create/edit the site.

server {
    listen 80;
    server_name webplace.example.br;

    location /subdirectory/ {
        proxy_pass  http://container_wordpress:80/subdirectory/;
        proxy_set_header   Host $host;
        proxy_set_header   X-Real-IP $remote_addr;
        proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header   X-Forwarded-Host $server_name;
    }

}

, after getting so much I ended up creating an alias in /etc/apache2/apache2.conf in the wordpress container, like this:

...
Alias /subdirectory /var/www/html
<Directory "/var/www/html">
    Options +Indexes
    AllowOverride All
</Directory>
...

After installing normally, I already activate the multisite by following these steps:

1st, added the line below, above /* That's all... in the wp-config.php file:

define ('WP_ALLOW_MULTISITE', true);

2st, soon after I updated the page, it was in tools> install network, it gave the 'ok', it adds this text just below the line previously entered in the same file:

define ('MULTISITE', true);
define ('SUBDOMAIN_INSTALL', false);
define ('DOMAIN_CURRENT_SITE', 'webplace.example.br');
define ('PATH_CURRENT_SITE', '/subdirectory/');
define ('SITE_ID_CURRENT_SITE', 1);
define ('BLOG_ID_CURRENT_SITE', 1);

3st, and this part in .htaccess , commenting on everything else:

RewriteEngine On
RewriteBase /subdirectory/
RewriteRule ^index\.php$ - [L]

# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) var/www/html/$2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ var/www/html/$2 [L]
RewriteRule . index.php [L]

With this the site continues to work normal, but when I create another site, I put some things in it and I try to access it, the site is all broken without style, pure text only, and it gets worse when I try to access wp-admin from multisite it does not even open and says that it redirected too much, to get an idea the url looks like webplace.example.br/subdirectory/<multisite>/wp-admin .

Can anyone see a light at the end of the tunnel or do you think it will never work?

Note3: I have tried several tutorials, but they never cover all the things I use (reverse proxy (nginx), subdirectory, multisite, container, wordpress (apache)), making them not work.

Note4: There are chances that I have not understood or implemented the tutorial solutions right.

Note5: Another type of implementation I am also accepting.

Try this:

Create a subdomain for your wordpress instance eg blog.example.com .

Set the subdomain up on your NGINX reverse proxy to point to your wordpress container

Install WordPress via the blog.example.com subdomain

Update your reverse proxy so /blog also points to your wordpress container

Your wordpress will be accessible via blog.example.com and example.com/blog .

When you visit example.com/blog all your wp-includes/wp-content will be loaded via the blog.example.com site while WordPress will continue to let you visitors click around remaining on the example.com/blog site

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM