反向代理管理问题背后的Wordpress

时间:2013-08-26 11:56:51

标签: wordpress reverse-proxy

基本上如标题所示我在逆向代理后面有一个wp。 比方说,域名是 ,而wordpress是* *** / blog 以下是wp-config.php编辑,允许它以这种方式工作:

define('.ADMIN_COOKIE_PATH.', '/blog');
define('.COOKIE_DOMAIN.', 'www.***.com');
define('.COOKIEPATH.', '/blog');
define('.SITECOOKIEPATH.', '.');


if(isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
        $list = explode(',',$_SERVER['HTTP_X_FORWARDED_FOR']);
        $_SERVER['REMOTE_ADDR'] = $list[0];
  }
define('DOMAIN_CURRENT_SITE', 'https://www.***.com/blog');
define('WP_HOME','https://www.***.com/blog');
define('WP_SITEURL','https://www.***.com/blog');
$_SERVER['REMOTE_ADDR'] = 'https://www.***.com/blog';
$_SERVER['HTTP_HOST'] = 'www.***.com/blog';
$_SERVER[ 'SERVER_ADDR' ] = 'www.***.com/blog';


define('FORCE_SSL_ADMIN', true);
define('FORCE_SSL_LOGIN', true);
if ($_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')
       $_SERVER['HTTPS']='on';

$_SERVER['REQUEST_URI'] = str_replace("https://www.***.com/wp-admin",
                                      "https://www.***.com/blog/wp-admin",
                                      $_SERVER['REQUEST_URI']);

现在,这一切都很完美,但是当我在管理面板中的某些地方时,让我们说评论,如果我提交表单,WP会转到 * / wp -admin而不是 * / blog / wp-admin并崩溃到404.

更新

尝试了VHost方法,将其添加到我的httpd.conf

Listen 80 <VirtualHost *:80> 
  DocumentRoot /var/www/wp-admin 
  ServerName https://***/blog/wp-admin 

# Other directives here 
</VirtualHost> 

但奇怪的是每当我去/博客后都有一个重定向循环

我该如何解决这个问题?

1 个答案:

答案 0 :(得分:2)

$ _ SERVER [&#39; REQUEST_URI&#39;]不包含完整的网址,因此您应该只替换/ wp-admin /。举个例子:

 $_SERVER['REQUEST_URI'] = str_replace("/wp-admin/", "/blog/wp-admin/",
                                            $_SERVER['REQUEST_URI']);