Help with API on VPS

I moved my dolibarr to a linux VPS and since then the API endpoint does not work.

This is my nginx configuration:

server {
    listen 80;
    server_name [ip-adress];

    root /opt/dolibarr/htdocs;

    index index.php;

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

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/run/php/php7.4-fpm.sock;
    }

    location ~ /\.ht {
        deny all;
    }
}

I replaced my VPS IP with [ip-adress]
My version is 14.0.5
Any ideas?

I this a solution?
Module Web Services API REST (developer) - Dolibarr ERP CRM Wiki

fastcgi_param  PATH_INFO       $fastcgi_path_info;
fastcgi_param  PATH_TRANSLATED $document_root$fastcgi_script_name;

@egils does it work from inside your VPS if you use something like curl to reach the API?

what is the error message if any?

try with curl from outside the VPS and post that error message too

My config :

server {
  listen       *:443 ssl http2;
  listen       [::]:443 ssl http2 ;


  server_name  xxx.com;

  ssl_certificate           /etc/letsencrypt/live/xxx.com/fullchain.pem;
  ssl_certificate_key       /etc/letsencrypt/live/xxx.com/privkey.pem;
  ssl_trusted_certificate   /etc/letsencrypt/live/xxx.com/chain.pem;

  index  index.html index.htm index.php;
  access_log            /var/log/nginx/ssl-xxx.com_ssl.access.log;
  error_log             /var/log/nginx/ssl-xxx.com_ssl.error.log;


  root /var/www/users/dol/xxx.com/web/;
      add_header "X-Robots-Tag" "noindex";


  location ~ \.php(/|$) {
    include /etc/nginx/fastcgi_params;
    set $path_info $fastcgi_path_info;
    add_header "X-Robots-Tag" "noindex";
    include       /etc/nginx/fastcgi.conf;

    fastcgi_pass  unix:/var/run/php8.2-fpm-dol.sock;
    fastcgi_index index.php;
    fastcgi_split_path_info ^(.+?\.php)(/.*)$;
    fastcgi_param PATH_INFO       $path_info;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    try_files $fastcgi_script_name =404;
    fastcgi_buffer_size 32k;
    fastcgi_buffers 8 16k;
    fastcgi_busy_buffers_size 32k;
    fastcgi_intercept_errors on;
  }
}
1 Like

@libremaster
I copied your location protocol, and it works like a charm now. Thank you for sharing! :star_struck:

1 Like