admin管理员组文章数量:1122832
I'm trying to create a working configuration for a wordpress multisite using subdomains behind a nginx reverse proxy using subdirectories.
There a two domains hosted on Plesk server A running nginx (domain.de and domain.at). The wordpress multisite is hosted on a different Plesk server B running apache (wpmulti.de with two sudomains sub1.wpmulti.de and sub2.wpmulti.de). Both domains on Plesk server A should proxy the subdirectory "blog" to their corresponding wordpress subdomain i.e. domain.de/blog -> sub1.wpmulti.de and domain.at/blog -> sub2.wpmulti.de.
For simplicity i will only mention domain.de, wpmulti.de and sub1.wpmulti.de from now on. The config for domain.at and sub2.wpmulti.de should work exactly the same after adjusting the domain names.
I've added the following location rule to the nginx config of domain.de:
location = /blog/ {
rewrite ^ /blog permanent;
}
location ^~ /blog {
proxy_set_header Accept-Encoding "";
sub_filter 'sub1.wpmulti.de' '$host';
sub_filter_once off;
proxy_pass ;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Port $server_port;
}
I've also added the following lines to the wp-config.php
of wpmulti.de:
define('ADMIN_COOKIE_PATH', '/');
define('COOKIE_DOMAIN', '');
define('COOKIEPATH', '');
define('SITECOOKIEPATH', '');
if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && 'https' == $_SERVER['HTTP_X_FORWARDED_PROTO']) {
$_SERVER['HTTPS'] = 'on';
}
if (isset( $_SERVER['HTTP_X_FORWARDED_HOST'] ) ) {
$_SERVER['REMOTE_PORT'] = $_SERVER['HTTP_X_FORWARDED_PORT'];
}
The .htaccess
file of wpmulti.de looks like this:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
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).*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
RewriteRule . index.php [L]
</IfModule>
I've also changed siteurl
and home
to domain.de/blog for sub1.wpmulti.de. Furthermore permalinks
are set to /%postname%
.
Still there is a major problem with this setup that I can't seem to resolve. There are no trailing slashes and I can only use a static homepage. When using the wordpress default, latest posts, the homepage is stuck in a redirect loop (with and without trailing slash).
So far I've tried a few different things:
- Remove the
location = /blog/
location rule and adding trailing slashes tositeurl
,home
andpermalinks
. This does work when using latest posts but when using a static homepage domain.de/blog/ ends in a redirect loop - Remove the
location = /blog/
location rule, add a trailing slash tolocation ^~ /blog
andproxy_pass
, change the sub filter tosub_filter 'sub1.wpmulti.de' '$host/blog';
. This works with both the latest posts and static homepage. However the backend is not really usable in this state. A lot of functions, including the search bars as an example, are missing the "blog" slug and redirect to domain.de/wp-admin (instead of domain.de/blog/wp-admin). - Not using a
sub_filter
but instead changing the header and/or$_SERVER
variable. As soon as i try to change theHTTP_HOST
either by usingproxy_set_header Host domain.de;
or by setting it inwp-config.php
with$_SERVER['HTTP_HOST'] = $_SERVER['HTTP_X_FORWARDED_HOST'];
the entire page just redirects to the network root page wpmulti.de. I've also tried many combinations with trailing slashes, with the blog subdirectory, and changing other variables as well (such as$_SERVER['REQUEST_URI']
)
I'm trying random things at this point. This should be possible but I can't figure it out. Any help is appreciated.
本文标签: directoryWordpress multisite with subdomains behind nginx reverse proxy using subdirectories
版权声明:本文标题:directory - Wordpress multisite with subdomains behind nginx reverse proxy using subdirectories 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736302507a1931558.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论