Nginx and osTicket 1.8 configuration

Recently when switching from Apache to Nginx for osTicket 1.8, I found that some functionality does not work properly. For example, when replying to customer’s via SCP, line break character does not display properly. In addition, some ajax-based features are not worked any more. After digging a little bit, I can solve the problem with nginx configuration. So in this quick note, I will mention on how to configure nginx and osTicket 1.8 so that they can live together 😛

First, assume that we have a website athttps://www.domain.com and the osTicket 1.8 is located at https://www.domain.com/support . We also configure to run the osTicket on Nginx, PHP-FPM and MariaDB stack.

In Nginx configuration, we will need to add the following configuration for osTicket to work properly:

#-- Quick fix will go with $path_info parameter
set $path_info "";
        # Requests to /api/* need their PATH_INFO set, this does that
        if ($request_uri ~ "^/support/api(/[^\?]+)") {
                set $path_info $1;
        }

        # /api/*.* should be handled by /api/http.php if the requested file does not exist
        location ~ ^/support/api/(tickets|tasks)(.*)$ {
                try_files $uri $uri/ /support/api/http.php;
        }

        # /scp/ajax.php needs PATH_INFO too, possibly more files need it hence the .*\.php
        if ($request_uri ~ "^/support/scp/.*\.php(/[^\?]+)") {
                set $path_info $1;
        }

        # Make sure requests to /scp/ajax.php/some/path get handled by ajax.php
        location ~ ^/support/scp/ajax.php/(.*)$ {
                try_files $uri $uri/ /support/scp/ajax.php;
        }

    # Add trailing slash to */support requests.    
    rewrite /support$ $scheme://$host$uri/ permanent;

    #To access without index.php in the link
    location /support/ {
        try_files \$uri \$uri/ /support/index.php?$query_string;
    }

    # Process PHP files
    location ~ \.php {
        try_files $uri = 404;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        include /etc/nginx/fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
	fastcgi_param   PATH_INFO               $path_info;
    }

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *