[英]Dolibarr and nginx configuration - api REST doesn't work
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 響應,但我無權訪問登錄:
我應該有這個:
這工作得很好: 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;
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.