Help with osTicket url rewrite

Discussion in 'Third-party applications' started by Joseph Vandertol, Jul 24, 2013.

  1. Any and all help is appreciated.

    osTicket is a php based ticketing system. I have successfully installed the application and all is well except for the creation of tickets via email. The use a cron script to poll a pop server. I am using the scheduled task feature to hit a php script called rcron.php which in turn posts to their api that then calls the polling mechanism. I can't get this to work. There is a url rewrite which is required. I have imported the php script for apache but still I get the following error:

    HTTP/1.1 400 Bad Request Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 Pragma: no-cache Content-Length: 17 Content-Type: text/html; charset=UTF-8 Expires: Thu, 19 Nov 1981 08:52:00 GMT Server: Microsoft-IIS/7.5 Set-Cookie: PHPSESSID=1t2r8nn3d2vvh4kjbb6d4ubnr5; path=/ X-Powered-By: ASP.NET Date: Tue, 23 Jul 2013 19:10:55 GMT Connection: close URL not supported
    These is the php rewrite script.
    <IfModule mod_rewrite.c>

    RewriteEngine On

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} (.*/api)

    RewriteRule ^(.*)$ %1/http.php/$1 [L]

    </IfModule>

    <rule name="Imported Rule 1" stopProcessing="true">
    <match url="^(.*)$" ignoreCase="false" />
    <conditions logicalGrouping="MatchAll">
    <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
    <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
    <add input="{URL}" pattern="(.*/api)" ignoreCase="false" />
    </conditions>
    <action type="Rewrite" url="{C:1}/http.php/{R:1}" />
    </rule>
     
  2. mjp

    mjp

  3. Thanks for the reply. I have done this already. The bottom of the post is the IIS rewrite which was generated when I imported the PHP script. I'm looking for someone who knows PHP and can tell me if the IIS rule is correctly imported.
     
  4. FrankC

    FrankC DiscountASP.NET Staff

    The conversion looks correct to me. What is the URL that generate this error?
     
  5. www.demandadvantage.com/support/api/tasks/cron. the scheduler is setup to hit www.demandadvantage.com/support/api/rcron.php. I'm not a PHP guy but it looks like curl is used to post to the above URL. The reason for this from osTicket is that a post with header information is required and the scheduler only does a get. It's really hard to resolve because it don know what the expected values is by the PHP script. Its all Greek to me.

    I have the PHP script.

    Really appreciate the help.
     
  6. FrankC

    FrankC DiscountASP.NET Staff

  7. That is my question. How come it is causing an error? I don't know iis rewrite very well. I don't know php so it's hard for me to say where the problem is because I don't have the technical skill set. I really appreciate your help on the IIS rewrite. To solve this problem someone would need to know IIS and php to troubleshoot the issue. It could be an issue with osTicket. I have posted to their forums and have not gotten much back. Perhaps I am not from the right part of town being that I am attempting to host osTicket on IIS. As a back up plan I have set up osTicket on another host provider that is php. If that goes well, I'll give up and modify the CNAME for support.demandadvantage.com to point to the PHP host.

    Once again thanks for your help.
     
  8. FrankC

    FrankC DiscountASP.NET Staff

    can you send me some documentation so i can take a quick peek?
     
  9. Documentation from osTicket on pop3 polling: http://osticket.com/wiki/Email_Settings#POP3.2FIMAP_Polling. An os support tech said the rewrite url rule was wrong provided the attached web config. I tested the rule conditions and the following backlinks were created:
    {R:0} www.demandadvantage.com/support/api/rcron.php
    {R:1} www.demandadvantage.com/support/api
    {R:2} rcron.php

    given the rewrite rule:

    <action type="Rewrite" url="{R:1}api/http.php/{R:2}"/>

    should resolve to be www.demandadvantage.com/support/api/api/http.php/rcron.php.

    I tried
    <action type="Rewrite" url="{R:1}/http.php/{R:2}"/>
    <action type="Rewrite" url="{R:1}http.php/{R:2}"/>

    both with the same result of 404 not found. This is probably better error than the 400 I was getting.
     

    Attached Files:

  10. FrankC

    FrankC DiscountASP.NET Staff

  11. Their docs all say /api/tasks/cron. You can't reference cron.php directly because it is a post with header info. That is what rcron.php does. Creates a post. Why it posts to ../api/tasks/cron and not ../api/cron.php I dont know
     
  12. FrankC

    FrankC DiscountASP.NET Staff

    hmmm.. that's not what i read.

    Here's from their doc


    Some hosts do not allow adding cron jobs, and instead only allow you to probe scripts located at a publicly accessible URL. In this case, you will schedule the task using your webhost's scheduling interface and http://domain/path/to/osticket/api/cron.php.

    have you tried it?
     
  13. FrankC

    FrankC DiscountASP.NET Staff

    do you mind if i test your app in our dev?
     
  14. FrankC

    FrankC DiscountASP.NET Staff

    i think i have an idea for you

    1) Create an asp.net script that spawn a process
    2) Execute this command

    C:\php-fastcgi\php.exe E:\web\demandadvan\htdocs\support\api\cron.php

    3) Use scheduled task to ping the page you created
     
  15. I have no issue with you testing the app in your dev. I think that is a good idea. I saw a post saying that they solved the issue by creating an asp page that called the cron process locally. I just don't know how to do that.

    I appreciate your help once again.
     
  16. FrankC

    FrankC DiscountASP.NET Staff

    You would do something like this

    System.Diagnostics.Process.Start("C:\php-fastcgi\php.exe","E:\web\demandadvan\htdocs\support\api\cron.php")
     
  17. I didn't think i had rights to access an exe from in an ASP page on discountasp. I'll give it a try.
     
  18. Okay we are getting a bit further along. I created a one page website in a folder called pingCron. In the code behind for the on_page event I added the above code. When this page is called by the scheduler it returns a 301 code and osTicket does not pick up the email. When I hit the url www.demandadvantage.com/pingCron from my browser it works.
     
  19. FrankC

    FrankC DiscountASP.NET Staff

  20. That worked!

    Frank thank you very much for you help on this. I was truly at the end of my rope.
     
    mjp likes this.
  21. FrankC

    FrankC DiscountASP.NET Staff

    Glad it worked out.. its kinda a strange way how the software does the API call.
     
    mjp likes this.
  22. I understand that they need header information because they treat this call as a use of the API, but why they post that page to a non-existent URL requiring a URL rewrite is beyond me. I saw other posts saying that the way this was handled even for PHP calls has issues. Thanks again for the help.
     
  23. Would you be so kind Frank tell me if osTicket supports http request? if does, pls some little example.. or how.
    Thank you very much
    Mike
     

Share This Page