Horde Groupware ActiveSync URL 的 Nginx 别名或重写不处理 rpc.php 文件

Horde Groupware ActiveSync URL 的 Nginx 别名或重写不处理 rpc.php 文件

我正在尝试使用 Nginx 设置 Horde 群件。Web 界面可以工作,但我无法让 ActiveSync 特定 URL 工作。Horde Wiki 解释了如何将其与 Apache Web 服务器一起使用这里

/horde/Microsoft-Server-ActiveSync我的问题是,我设置了一个重写(也尝试了一个别名)来通过脚本提供位置/horde/rpc.php。但是根据我当前的配置,nginx 会进行重写并返回 200 状态代码。但看起来 php 文件未执行。如果我直接转到,/horde/rpc.php它会打开登录对话框。所以这似乎工作正常。

首先,我在 Google 上搜索了这个问题,但没有找到可行的解决方案。所以现在我想问你。

配置应允许通过 URL 访问 ActiveSync 部分/horde/Microsoft-Server-ActiveSync。Horde Web 界面已可通过 访问/horde

我的配置如下:

默认 SSL 配置文件

server {
        listen                  443 ssl;
        ssl                     on;
        ssl_certificate         /opt/nginx/conf/certs/server.crt;
        ssl_certificate_key     /opt/nginx/conf/certs/server.key;
        server_name             example.com;
        index                   index.html index.php;
        root                    /var/www;

        include sites-available/horde.conf;
}

部落配置文件

location /horde {
        rewrite_log on;
        rewrite ^/horde/Microsoft-Server-ActiveSync(.*)$ /horde/rpc.php$1 last;

        try_files $uri $uri/ /rampage.php?$args;

        location ~ \.php$ {
                try_files $uri =404;
                include sites-available/horde.fcgi-php.conf;
        }
}

horde.fcgi-php.conf

include fastcgi_params;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

fastcgi_params(默认 nginx)

fastcgi_param  QUERY_STRING       $query_string;
fastcgi_param  REQUEST_METHOD     $request_method;
fastcgi_param  CONTENT_TYPE       $content_type;
fastcgi_param  CONTENT_LENGTH     $content_length;

fastcgi_param  SCRIPT_NAME        $fastcgi_script_name;
fastcgi_param  REQUEST_URI        $request_uri;
fastcgi_param  DOCUMENT_URI       $document_uri;
fastcgi_param  DOCUMENT_ROOT      $document_root;
fastcgi_param  SERVER_PROTOCOL    $server_protocol;
fastcgi_param  HTTPS              $https if_not_empty;

fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;
fastcgi_param  SERVER_SOFTWARE    nginx/$nginx_version;

fastcgi_param  REMOTE_ADDR        $remote_addr;
fastcgi_param  REMOTE_PORT        $remote_port;
fastcgi_param  SERVER_ADDR        $server_addr;
fastcgi_param  SERVER_PORT        $server_port;
fastcgi_param  SERVER_NAME        $server_name;

# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param  REDIRECT_STATUS    200;

nginx日志级别设置为debug,请求后的输出为:

2014/06/13 10:33:15 [notice] 17332#0: *1 "^/horde/Microsoft-Server-ActiveSync(.*)$" matches "/horde/Microsoft-Server-ActiveSync", client: XX.XX.XX.XX, server: example.com, request: "GET /horde/Microsoft-Server-ActiveSync HTTP/1.1", host: "example.com"
2014/06/13 10:33:15 [notice] 17332#0: *1 rewritten data: "/horde/rpc.php", args: "", client: XX.XX.XX.XX, server: example.com, request: "GET /horde/Microsoft-Server-ActiveSync HTTP/1.1", host: "example.com"

所有这些都发生在装有 Raspbian GNU/Linux 7 的 RaspberryPi 上(主要是 Debian Wheezy)。所以我猜重写有效,但 php 文件未被处理?!有人知道问题出在哪里以及如何修复它吗?

更新: 如果我将文件更改rpc.phpmytest.php以下内容:

<pre>
<?php var_export( $_SERVER ); ?>
</pre>

并将重写内容更改为

rewrite ^/horde/Microsoft-Server-ActiveSync(.*)$ /horde/mytest.php$1 last;

我得到了正确的输出:

array (
  'USER' => 'www-data',
  'HOME' => '/var/www',
  'FCGI_ROLE' => 'RESPONDER',
  'QUERY_STRING' => '',
  'REQUEST_METHOD' => 'GET',
  'CONTENT_TYPE' => '',
  'CONTENT_LENGTH' => '',
  'SCRIPT_NAME' => '/horde/mytest.php',
  'REQUEST_URI' => '/horde/Microsoft-Server-ActiveSync',
  'DOCUMENT_URI' => '/horde/mytest.php',
  'DOCUMENT_ROOT' => '/var/www',
  'SERVER_PROTOCOL' => 'HTTP/1.1',
  'GATEWAY_INTERFACE' => 'CGI/1.1',
  'SERVER_SOFTWARE' => 'nginx/1.4.4',
  'REMOTE_ADDR' => 'XX.XX.XX.XX',
  'REMOTE_PORT' => '25330',
  'SERVER_ADDR' => 'XX.XX.XX.XX',
  'SERVER_PORT' => '80',
  'SERVER_NAME' => 'example.com',
  'REDIRECT_STATUS' => '200',
  'PATH_INFO' => '',
  'PATH_TRANSLATED' => '/var/www',
  'SCRIPT_FILENAME' => '/var/www/horde/mytest.php',
  'HTTP_HOST' => 'example.com',
  'HTTP_USER_AGENT' => 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Firefox/24.0',
  'HTTP_ACCEPT' => 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
  'HTTP_ACCEPT_LANGUAGE' => 'en-US,en;q=0.5',
  'HTTP_ACCEPT_ENCODING' => 'gzip, deflate',
  'HTTP_DNT' => '1',
  'HTTP_COOKIE' => 'XXX',
  'HTTP_IF_MODIFIED_SINCE' => 'Thu, 12 Jun 2014 11:56:09 GMT',
  'HTTP_CACHE_CONTROL' => 'max-age=0',
  'HTTP_CONNECTION' => 'keep-alive',
  'PHP_SELF' => '/horde/mytest.php',
  'REQUEST_TIME_FLOAT' => 1402664378.2101,
  'REQUEST_TIME' => 1402664378,
)

那么为什么 rpc.php 无法正常工作?如果我理解正确的话,它会尝试建立一个基本的身份验证过程。这会是个问题吗?

答案1

经过更多尝试和查看日志(最终找到正确的日志)后,我发现我的故障。毕竟这是配置错误。

Horde Wiki 仅用一行就给出了提示:

要激活服务器,需要在 Horde 的配置中的 ActiveSync 选项卡中启用它。

这给了我正确的方向:我在配置中搜索但找不到 ActiveSync 的东西。所以我深入挖掘并最终意识到我没有安装库 Horder_ActiveSync。 :(

sudo pear install horde/horde_activesync从 WebUI执行并更新数据库表后,一切正常!

希望这对其他人有帮助。

相关内容