Ad Widget

Collapse

Error 404 when trying to access API

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • erppsd5
    Junior Member
    • Jul 2023
    • 11

    #1

    Error 404 when trying to access API

    Hello so ive deployed Zabbix using Docker Compose and its running fine, but i cant access the API using:
    curl --request POST \
    --url 'http://example.com/zabbix/api_jsonrpc.php' \
    --header 'Content-Type: application/json-rpc' \
    --data '{"jsonrpc":"2.0","method":"apiinfo.version","pa ra ms":{},"id":1}'

    Obviously I have replaced example.com with my ip where I also access the webfront from.
    Looking in my Docker container I can find the Physical file api_jsonrpc.php.
    When I try to open the URL http://example.com/zabbix/api_jsonrpc.php it just says file not found which is odd. The path of the file is /usr/share/zabbix/.
    I have tried the other solutions suggesting removing the /zabbix/ which also doesnt work

    Im using Postgresql with Nginx(the ubuntu version) on Docker Desktop on Windows 10
  • erppsd5
    Junior Member
    • Jul 2023
    • 11

    #2
    here is the call from inside the docker container
    Attached Files

    Comment

    • erppsd5
      Junior Member
      • Jul 2023
      • 11

      #3
      Okay i somehow fixed it, no idea how or what this does but adding

      location /api_jsonrpc.php {
      try_files $uri =404;
      fastcgi_pass unix:/tmp/php-fpm.sock;
      fastcgi_param SCRIPT_FILENAME $webroot/api_jsonrpc.php;
      include fastcgi_params;
      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_intercept_errors on;
      fastcgi_ignore_client_abort off;
      fastcgi_connect_timeout 60;
      fastcgi_send_timeout 180;
      fastcgi_read_timeout 601;
      fastcgi_buffer_size 128k;
      fastcgi_buffers 4 256k;
      fastcgi_busy_buffers_size 256k;
      fastcgi_temp_file_write_size 256k;
      }

      this to /etc/zabbix/nginx.conf fixed it, probably have to do it aswell for nginx_ssl.conf if youre using https make sure to restart the server.​

      Comment

      Working...