Hope this is what you were looking for. When logged in as USER the response is:

file does not appear in the response field.

When logged in as Agent the response is:

and the file appears in the Response field,

Hope this makes any sense to you. I'm off to bed (Europe) but I will continue to work on this tomorrow.

Cheers, Hans

    HansAlbers

    You are supposed to click on the Response tab within the Network tab after clicking on the POST request.

    Cheers.

    Hi Kevin,

    The response is not what it should be and after having tested from two different computers here, in the same network, same Chrome browser, we even get different results. On my computer:

    on my colleague's computer:

    From this response, it seems osTicket is redirecting to the agent login page?!?!

    I have a test instance running on another server, where it works fine, on that server, the response is:

    I must admit that instance has some differences. The osTicket version is exactly the same. But the one on which this attaching works fine is on PHP 8.3.13. while the one we have the issue with is on PHP 8.2.24. The other difference is that the system on which it works stores attachments in the database while on our problem-system (the real one) we store in the file system using the plugin. As said before, the puzzling part is that when logged in as agent, adding attachments works just fine, which uses the same filesystem plugin, I would think.

    Like you say it is mysterious. I would understand that you don't have a solution right away. But any suggestions about further troubleshooting we could do? Like putting extra loggings in any of the php code? Appreciate your help!

    Cheers, Hans

    For what it is worth:

    I found an option in Chrome developer mode to have it pause on exceptions and this is where it does so when attaching something logged in as user. When logged in as agent, no exception occurs.


    The full error line is:
    "SyntaxError: Unexpected token '<', "<!DOCTYPE "... is not valid JSON at Function.parse [as parseJSON] (<anonymous>) at xhr.onload (https://support.newland-id.com/js/filedrop.field.js?0375576:718:41)"
    You can even see the picture of the attachment I'm trying to upload. after clicking the play (after the break) button this disappears right away.

    Does this mean something to you?
    Greetings, Hans

      HansAlbers

      That simply means it’s expecting the ID response (which is JSON format) but it’s getting HTML in the response instead. What else is different between the setups? Also, PHP 8.3 is not fully supported yet so that install will run into some issues at some point.

      Cheers.

      Which .php or .js is giving back the ID response normally?

      About PHP version: We're having the issue on the instance running on PHP8.2. The test instance on 8.3. does not have this issue. I even installed the file system attachment plugin on the test instance like we have it on the production instance and this is working fine still on the test instance when using filesystem instead of database for attachments.

      What we simply don't understand is why this all works fine for agent logged in, but not for user logged in. Litterally on the same osTicket instance. What can it make behave so different?

      Greetings, Hans

        HansAlbers

        It's a mix of AJAX and PHP. Most likely the windows server or setup. I can't think of anything in the system would cause that.

        Cheers.

        At least we found out why the result on two differen PCs was different. One still was also logged in as agent, that's why the results were different. Now when both logged out as agent and ONLY logged in as USER, when trying to attach, we see in the Chrome debug screen that instead of doing the attachement the response from the attach action is a redirect to the agent login page. (/scp/login.php) which can be seen in this screenshot:

        So there seems to be a reason why osTicket rejects an attachment upload from a user and we have no clue what that reason is. Any suggestions as to how to find out that? Are there other settings, not visible in the osTicket UI, that could affect this?

        Thanks, Hans

          HansAlbers
          Could the permission be managed within the file system, given that his second system, which stores the database, is working fine?

            ramrajone

            That's what I was wondering but then I thought: "Why would it work for Agents and not Users if it was the filesystem?"

            Cheers.

            Yeah we have had a thousands of looks at the file permissions but find no reason in it. And as Kevin mentions, why does it work for agents and not for users? It's the same filesystem and permissions. BTW I already changed the test instance to also use file system, and it still works there. Even while the test instance runs on newer PHP that is not yet officially supported by osTicket. I will try and see if I can downgrade the PHP on the test instance to the same as on our production server to see if I can then duplicate the problem there.

            Hans

              HansAlbers

              Ah, I went back and realized you are using NGINX; don't know how I missed that the first time. Compare your NGINX config with the below and see if you are missing anything. If so update yours, run the NGINX test command on the config file to make sure nothing will break, reload NGINX, and retest.

              user  nginx;
              worker_processes 1;
              
              events {
                  worker_connections  1024;
              }
              
              http {
                  include         mime.types;
                  default_type    application/octet-stream;
                  sendfile        on;
                  charset         utf-8;
                  gzip            on;
                  gzip_types      text/plain application/xml text/javascript;
                  gzip_min_length 1000;
              
                  index index.php index.html index.htm;
              
                  # Rewrite all requests from HTTP to HTTPS
                  server {
                      listen 80;
                      server_name tickets.mydomain.com;
                      rewrite ^ https://tickets.mydomain.com permanent;
                  }
              
                  server {
                      listen 443;
                      server_name tickets.mydomain.com;
                      ssl on;
                      ssl_certificate /etc/nginx/certs/cert.pem;
                      ssl_certificate_key /etc/nginx/certs/cert.key;
              
                      keepalive_timeout 70;
              
                      root /var/www/osticket;
              
                      set $path_info "";
              
                      location ~ /include {
                          deny all;
                          return 403;
                      }
              
                      if ($request_uri ~ "^/api(/[^\?]+)") {
                          set $path_info $1;
                      }
              
                      location ~ ^/api/(?:tickets|tasks).*$ {
                          try_files $uri $uri/ /api/http.php?$query_string;
                      }
              
                      if ($request_uri ~ "^/scp/.*\.php(/[^\?]+)") {
                          set $path_info $1;
                      }
              
                      if ($request_uri ~ "^/.*\.php(/[^\?]+)") {
                          set $path_info $1;
                      }
              
                      location ~ ^/scp/ajax.php/.*$ {
                          try_files $uri $uri/ /scp/ajax.php?$query_string;
                      }
              
                      location ~ ^/ajax.php/.*$ {
                          try_files $uri $uri/ /ajax.php?$query_string;
                      }
              
                      location / {
                          try_files $uri $uri/ index.php;
                      }
              
                      location ~ \.php$ {
                          fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
                          include        fastcgi_params;
                          fastcgi_param  PATH_INFO        $path_info;
                          fastcgi_pass   127.0.0.1:8888;
                      }
                  }
              }

              Cheers.

              Hi Kevin,

              Took a while to respond cause I had to get with the guy who manages the webserver part (nginx). I gave him your suggestion to edit the nginx configuration and he said he did, made some corrections to what you gave us but after all now it all works again. First of all a big thank you for helping here and pointing us into the right direction.
              Just a question out of curiosity: Do you know or can you explain why we ran into this issue on nginx while on our testinstance, that is running on LightSpeed, this was not caused any issue and we didn't need to configure anything to make it work on that instance? When I asked the webserver admin why it was an issue on nginx he said:
              "Nginx was not issue, the issue was osticket needs special URI for ajax.php. You can see this URI was accessed: /ajax.php/form/upload/ticket/attach. but there is no such file under ajax.php folder.
              I dont know how LiteSpeed handle the URI which is not pointed to actual files".
              he also mentioned "Lightspeed has rewrite engine to handle such jobs to rewrite the "fake" request to actual location."

              My question, is this a bug in osTicket, accessing wrong URI, that we are now correcting with the nginx configuration or do you see this differently?

              Again, big thanks for your help!

              Have a good weekend. Cheers, Hans

                HansAlbers

                The problem is NGINX is not supported out of the box. Go read the osTicket requirements to see what I'm saying. NGINX is supported just requires its own special config (additional setup). Litespeed is a drop-in replacement for Apache which is fully supported out of the box (ie. no custom config needed). We ship with the relevant .htaccess file and web.config files for Apache and IIS respectively. However, NGINX never worked like that as they saw it as tacky and security issue prone. So they make people add it the "right way" which means we can't ship with our own files that just "work out of the box".

                Cheers.

                Write a Reply...