[RESOLVED] PHP5 - Linklok IPN 503 error

Discussion in 'Bug Reports' started by chernann, Feb 13, 2010.

  1. chernann

    chernann Member

    This is a persistent problem I'm getting with Linklok IPN.

    Linklok is a small PHP script that serves files outside the webroot to users who authenticate via a embedded token in the URL.

    I've reproduced the relevant portion of the code here:

    function xfpassthru($file)
     if (
    When Litespeed is just restarted, everything works fine. However, after it's been running a while with multiple users accessing other portions of the site, we start getting 503 errors when file downloads are attempted (this is a 19meg file). The server does not auto attempt a restart when this happens. Once this error occurs, no more downloads are possible (all 503).

    This problem does not occur in Apache. We are using LSWS enterprise 4.12 and both Apache and LSWS are using the same version of PHP5.

    For now I'm running Apache in parallel JUST to support this script, on port 79. I can't figure out how to run LSWS on a negative port offset (it refuses this as a parameter) and some ISPs view sub-80 http ports as unsafe and refuse connections.
    Last edited by a moderator: Feb 25, 2010
  2. NiteWave

    NiteWave Administrator

  3. chernann

    chernann Member

    Thanks, didn't know litespeed had this feature. I'll mod the script and see if litespeed prefers that.

    Ok tried it out, since I'm using PHP I have to use
      	$header="X-LiteSpeed-Location: /".$link;
    However, this does not work, it doesn't even return an error. Did this feature make it into the Litespeed PHP5 binary build?
    I checked against a normal "Location :/".$link header and that worked just fine, however, it's doing a normal redirect in this case because I have a rewrite condition on the link which gives a 403 error and that is triggered. Could someone on Litespeed verify if this special header is in the PHP5 binary build for Litespeed? I built this using my Cpanel/Apache config and everything else works fine.
    Last edited: Feb 15, 2010
  4. mistwang

    mistwang LiteSpeed Staff

    It is a LiteSpeed internal feature. Only need the "X-LiteSpeed-location" header.
    Maybe you can try a simple test script, see if it works.
    the $link should be a URL different from the request URL, otherwise, it will become a loop redirect.
  5. chernann

    chernann Member

    I got it to work, but can't seem to get the redirect working properly. Anything that correctly creates a 403 also causes the redirect to 403.

    eg. my url is http://abc.com/1234/file.zip
    According to the wiki I am supposed to be matching for 1234/ to 403, and because litespeed is handling the redirect it should bypass this htaccess rule. However it still gives me a 403 error.
  6. NiteWave

    NiteWave Administrator

    I just did test on localhost(4.0.13 standard version), it's working as expected.

    rewrite rule:
    when access directly:
    403 Forbidden

    when access via
    output content of /a/block/test.html
  7. chernann

    chernann Member

    PHP stream files method

    I just realized that this method needs to work properly or anyone using standard PHP scripts to deliver digital goods is going to have to rewrite a substantial amount of code in most shopping carts, and break forward compatibility. Zencart, OSCommerce, Magento etc all use PHP file streaming to secure digital goods.

    I am still getting 503 errors in my shopping cart after 4.013 is installed. In order to continue using Litespeed, can you modify the litespeed WHM plugin to allow port offsets of negative numbers? So I can run the file downloads on apache at 8080 and accept normal web connections on Litespeed on the default port 80.

    Or better yet, solve the 503 issue.
  8. mistwang

    mistwang LiteSpeed Staff

    There was a bug in LiteSpeed PHP-lsapi 5.3 release that may cause 503 errors.
    If you build PHP from our web console, please remove php-litespeed-5.3.tgz from
    /path/to/lsws/phpbuild/ directory then rebuild PHP.

    If you use WHM plugin to build PHP, you need t remove

    then build again.
  9. chernann

    chernann Member

    Just tried that, it seems to introduce a new bug breaking the phpThumb script which is a popular GD thumbnail generator. I've had to revert to Apache in the mean time.
  10. mistwang

    mistwang LiteSpeed Staff

  11. chernann

    chernann Member

    OK, nothing to do with litespeed but the upgrade to php 5.3, phpthumb is not compatible due to deprecated functions. I will continue to monitor digital downloads, but it looks stable so far.

Share This Page