我似乎无法让wordpress多站点子目录在我的反向代理之后工作。
本地(从lan ip地址)所有工作正常,我可以访问主域、子目录和所有仪表板。
添加反向代理时,我无法访问网络仪表板(重定向循环)或多站点子目录(重定向到lan ip)。如果我试图通过手动写入地址进入多站点,它会将我发送到没有css的页面。
唯一可以使用反向代理的是主站点。
我想要的:
www.example。net www.example。net/wp admin www.example。net/wp admin/network www.example。net/sub1 www.example。net/sub1/wp admin www.example。net/sub2 www.example。net/sub2/wp admin发生了什么:
www.example。net-->正常www.example。net/wp admin-->正常www.example。net/wp admin/network-->重定向循环www.example。net/sub1-->无css www.example。net/sub1/wp admin-->无css。net/sub2-->无css www.example。net/sub2/wp管理-->无css
Reverse Proxy conf
server {
listen 80;
server_name *.example.net example.net;
return 302 $scheme://www.example.net$request_uri;
}
server {
listen 80;
server_name www.example.net;
return 302 https://$host$request_uri;
}
server {
listen 443 ssl http2;
server_name www.example.net;
ssl on;
ssl_certificate /etc/letsencrypt/live/www.example.net/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/www.example.net/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
location ^~ / {
proxy_pass http://192.168.2.30/;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
wp-config.php
/* Updates asking for FTP */
define(\'FS_METHOD\',\'direct\');
/* Multisite */
define( \'WP_ALLOW_MULTISITE\', true );
define(\'MULTISITE\', true);
define(\'SUBDOMAIN_INSTALL\', false);
// define(\'DOMAIN_CURRENT_SITE\', \'192.168.2.30\');
define(\'DOMAIN_CURRENT_SITE\', \'www.example.net\');
define(\'PATH_CURRENT_SITE\', \'/\');
define(\'SITE_ID_CURRENT_SITE\', 1);
define(\'BLOG_ID_CURRENT_SITE\', 1);
/* Faire fonctionner SSL (et CSS) */
if ( (!empty( $_SERVER[\'HTTP_X_FORWARDED_HOST\'])) ||
(!empty( $_SERVER[\'HTTP_X_FORWARDED_FOR\'])) ) {
$_SERVER[\'HTTPS\'] = \'on\';
}
wordpress nginx conf
server {
listen 80 default_server;
server_name 192.168.2.30;
root /var/www/html/wordpress;
access_log /var/log/nginx/wp.access.log;
error_log /var/log/nginx/wp.error.log;
## WordPress Perm links config
location / {
index index.php index.html;
try_files $uri $uri/ /index.php?$args;
}
# Rewrite multisite in a subdirectory \'.../wp-.*\' and \'.../*.php\'.
if (!-e $request_filename) {
rewrite ^/[_0-9a-zA-Z-]+(/wp-.*) $1 last;
rewrite ^/[_0-9a-zA-Z-]+.*(/wp-admin/.*\\.php)$ $1 last;
rewrite ^/[_0-9a-zA-Z-]+(/.*\\.php)$ $1 last;
}
# Pass all .php files onto a php-fpm or php-cgi server
location ~ \\.php$ {
try_files $uri =404;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
}
}
如果我添加“proxy\\u set\\u header Host$Host”以反转代理配置,则在尝试访问wp admin时会出现此错误
Error establishing a database connection
If your site does not display, please contact the owner of this network. If you are the owner of this network please check that MySQL is running properly and all tables are error free.
Could not find site www.example.net. Searched for table wp_blogs in database wordpressDB. Is that right?
What do I do now? Read the bug report page. Some of the guidelines there may help you figure out what went wrong. If you’re still stuck with this message, then check that your database contains the following tables:
wp_users
wp_usermeta
wp_blogs
wp_signups
wp_site
wp_sitemeta
wp_registration_log
wp_blog_versions
仪表板不保留链接的域名(所有内容都重定向到ip)。我尝试将这段代码添加到wp配置中,但它仍然没有改变任何东西。定义(\'WP\\U HOME\',\'
https://www.example.net\'); 定义(\'WP\\U SITEURL\',\'
https://www.example.net\');