0

Dolibarr 版本:10.0.3 - api 文档:https://wiki.dolibarr.org/index.php/Module_Web_Services_API_REST_(developer)。我在 dolibarr 文档中找不到有关 nginx 配置的任何信息。但这似乎是一个nginx配置问题。

带有位置的 nginx 配置部分:

location / {
        try_files $uri $uri/ /index.php?$query_string;
}

location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
        fastcgi_index index.php;
        include fastcgi_params;
}

我测试了我发现的所有内容,但没有成功添加:

#test 1
rewrite ^/api/index.php/explorer(.*)$ /api/index.php last;

#test 2
location /api {
    if ( !-e $request_filename) {
         rewrite ^.* /api/index.php last;
    }
}

#test 3
location ~ ^/api/(?!(index\.php))(.*) {
    try_files $uri /api/index.php/$2?$query_string;
}

对于前 2 个解决方案,API api/index.php/explore 会响应,但我无权访问登录:

在此处输入图像描述

我应该有这个:

在此处输入图像描述

4

1 回答 1

1

这很好用: https ://wiki.dolibarr.org/index.php/Module_Web_Services_API_REST_(developer)#Nginx_setup

server {
    listen      80;
    server_name     dolibarr.localhost; # adjust to your domain

    root    /usr/share/webapps/dolibarr/htdocs; # adjust to your path 
    index   index.php;

    # from https://github.com/Dolibarr/dolibarr/issues/6163#issuecomment-391265538
    location ~ [^/]\.php(/|$) {
        fastcgi_split_path_info ^(.+?\.php)(/.*)$;
        if (!-f $document_root$fastcgi_script_name) {
            return 404;
        }

        # Mitigate https://httpoxy.org/ vulnerabilities
        fastcgi_param HTTP_PROXY "";

        root           /usr/share/webapps/dolibarr/htdocs;
        fastcgi_pass   unix:/run/php-fpm/php-fpm.sock;
        fastcgi_index  index.php;
        include        fastcgi_params;
        fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
        # Dolibarr Rest API path support
        fastcgi_param  PATH_INFO       $fastcgi_path_info;
        fastcgi_param  PATH_TRANSLATED $document_root$fastcgi_script_name;
    }
 }
于 2020-11-26T11:00:44.707 回答