【发布时间】:2016-11-07 10:14:57
【问题描述】:
我有一个静态服务的站点(使用 nginx)。 我想在 /blog 文件夹下托管一个 wordpress 博客(托管在不同的实例上)。 使用 nginx 代理时:
location /blog/ {
proxy_set_header X-Is-Reverse-Proxy "true";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_pass http://55.555.55.555;
}
以及以下 wp-config.php:
define('WP_SITEURL', 'http://' . $_SERVER['HTTP_HOST'] . '/');
define('WP_HOME', 'http://SOMESITE.com/blog/');
来自wp-content(和wp-includes)的所有文件都未正确提供,因为它们正在http://SOMESITE.com/wp-content/* 下进行搜索
而不是http://SOMESITE.com/blog/wp-content/*。
添加一些额外的代理规则不起作用,例如:
location ~* (\/wp-content) {
proxy_set_header X-Is-Reverse-Proxy "true";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_pass http://55.555.55.555;
}
也不重新定义wp-config.php:
define('WP_SITEURL', 'http://SOMESITE.com/blog/');
希望有任何想法。 我也很确定这是一个常见的用例,但在这里找不到任何有效的技巧。
谢谢。
【问题讨论】: