【问题标题】:activecollab 5 nginx url rewrite not workingactivecollab 5 nginx url重写不起作用
【发布时间】:2018-04-04 22:50:54
【问题描述】:

我试图按照instructions here 安装 Activecollab。

我的 nginx 虚拟主机配置是 here

server {
    listen *:80;
    server_name collab.example.com;
    access_log /var/log/nginx/ac.access.log;
    error_log /var/log/nginx/ac.error.log;

    set $root_path /usr/share/nginx/html/collabs/public;
    root $root_path;

    index index.html index.htm index.php router.php;
    charset utf-8;

    if (!-e $request_filename) {
        rewrite ^/assets/(.*)$ /assets/$1 last;
        rewrite ^/avatars/(.*)$ /avatars/$1 last;
        rewrite ^/wallpapers/(.*)$ /wallpapers/$1 last;
        rewrite ^/verify-existence$ /verify.php last;
        rewrite ^/proxy.php$ /proxy.php last;
        rewrite ^/api/v([0-9]*)/(.*)$ /api.php?path_info=$2&api_version=$1 last;
        rewrite ^$ /router.php last;
        rewrite ^(.*) /router.php?path_info=$1 last;
    }


    location ~ ^/(assets|avatars|wallpapers)/ {
        root $root_path;
    }

    location = /robots.txt {
        allow all;
        log_not_found off;
        access_log off;
    }


    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_read_timeout 150;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include /etc/nginx/fastcgi_params;
    }

}

nginx -V的输出

nginx version: nginx/1.10.3 (Ubuntu) built with OpenSSL 1.0.2g 1 Mar 2016 TLS SNI support enabled configure arguments: --with-cc-opt='-g -O2 -fPIE -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2' --with-ld-opt='-Wl,-Bsymbolic-functions -fPIE -pie -Wl,-z,relro -Wl,-z,now' --prefix=/usr/share/nginx --conf-path=/etc/nginx/nginx.conf --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log --lock-path=/var/lock/nginx.lock --pid-path=/run/nginx.pid --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --with-debug --with-pcre-jit --with-ipv6 --with-http_ssl_module --with-http_stub_status_module --with-http_realip_module --with-http_auth_request_module --with-http_addition_module --with-http_dav_module --with-http_geoip_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_image_filter_module --with-http_v2_module --with-http_sub_module --with-http_xslt_module --with-stream --with-stream_ssl_module --with-mail --with-mail_ssl_module --with-threads

我遇到错误

错误 — 未启用 URL 重写。无效的 URL 重写检查响应:

感谢任何帮助。

【问题讨论】:

  • 运行nginx -t时会发生什么?
  • @TarunLalwani 它的工作,我可以看到我的其他网站。 nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
  • 您在哪里得到您指定的错误?也请在您的问题中添加nginx -V 输出
  • @TarunLalwani 看到我的编辑。
  • 您没有更新您在哪里看到此错误?你能详细说明一下吗?

标签: nginx url-rewriting activecollab


【解决方案1】:

Tarun 的帮助下,我设法解决了这个问题。我们所做的是

  1. 确认这与nginx和规则无关
  2. 在配置文件中禁用了 REDIRECT_CHECK。

现在它似乎工作正常。

【讨论】:

  • 用我们的发现添加了详细的答案
  • @TarunLalwani 投票赞成并发放赏金,btc 将紧随其后。
【解决方案2】:

正如在聊天和 teamviewer 调试会话中讨论的那样。在config.php 中有一个标志REDIRECT_CHECK 用于activecollab。您需要通过在配置中定义此名称来禁用此重定向

define('REDIRECT_CHECK',false);

您还应该更改以下部分的 nginx 配置

if (!-e $request_filename) {
    rewrite ^/assets/(.*)$ /assets/$1 last;
    rewrite ^/avatars/(.*)$ /avatars/$1 last;
    rewrite ^/wallpapers/(.*)$ /wallpapers/$1 last;
    rewrite ^/verify-existence$ /verify.php last;
    rewrite ^/proxy.php$ /proxy.php last;
    rewrite ^/api/v([0-9]*)/(.*)$ /api.php?path_info=$2&api_version=$1 last;
    rewrite ^$ /router.php last;
    rewrite ^(.*) /router.php?path_info=$1 last;
}

location / { 
  if (!-e $request_filename) { 
     rewrite ^/assets/(.*)$ /assets/$1 last; 
     rewrite ^/avatars/(.*)$ /avatars/$1 last; 
     rewrite ^/wallpapers/(.*)$ /wallpapers/$1 last; 
     rewrite ^/verify-existence$ /verify.php last; 
     rewrite ^/proxy.php$ /proxy.php last; 
     rewrite ^/api/v([0-9]*)/(.*)$ /api.php?path_info=$2&api_version=$1 last; 
     rewrite ^$ /router.php last; 
     rewrite ^(.*) /router.php?path_info=$1 last; 
   } 
   try_files $uri $uri/ /router.php?path_info=$uri&$args; 
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-10-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多