nested ErrorDocuments not working

Discussion in 'Apache Migration/Compatibility' started by aww, May 15, 2007.

  1. aww

    aww New Member

    I just realized that nested ErrorDocuments are not working in my older 3.1.1 copy (I will have to wait until a lighter load overnight to upgrade to the 3.1.1 final release but this might be wrong in both)

    ie.

    /public_html/missing-example.html can have one errordocument in htaccess

    /public_html/images/missing-image.jpg could be a lower level .htaccess in images overriding the one above it

    Works perfectly in apache. Not in LiteSpeed. LiteSpeed shows the top ErrorDocument. Actually, possibly the LAST errordocument for that error code it processed.

    ie.
    /.htaccess
    /images/.htaccess
    /blog/.htaccess

    The errordocument for 404 in /blog/ will be shown if a 404 occurs in /images/ or /

    At least in my working server. You might want to test this on 3.1.1 production, otherwise I will also test it on the latest tonight.
    Last edited: May 15, 2007
  2. mistwang

    mistwang LiteSpeed Staff

    It works fine in lab environment, maybe it is caused by something else.
  3. aww

    aww New Member

    Well I am experiencing ErrorDocument issues.

    1. Upgraded to 3.1.1 final release

    2. Created a brand new fresh account under cpanel called "demosite"

    3. made a test document index.html

    4. http://ipaddress/~demosite/index.html
    works as expected

    5. http://ipaddress/~demosite/blahblahblah
    gives proper litespeed generic 404 page

    6. create and upload .htaccess with single line:
    ErrorDocument 404 "missing

    7. http://ipaddress/~demosite/blahblahblah
    server thinks about it for a few seconds and then times out with a blank page - view source shows it's blank


    note this step on apache with same httpd.conf & .htaccess produces proper "missing" message
    Last edited: May 16, 2007
  4. aww

    aww New Member

    I've traced the additional nested htaccess errordocument issues to litespeed being overly aggressive on rewrite issues in the topmost .htaccess

    however the issue is so complex that I am having difficultly producing a simple example - will have to work on it - note that the issues do not exist when apache is running, it interprets the nested rules perfectly
  5. mistwang

    mistwang LiteSpeed Staff

    Can you turn on the debug logging by set "DEBUG Level" to "HIGH", then reproduce it. Please post the related log entries by greping your IP.
  6. mistwang

    mistwang LiteSpeed Staff

    You can try turning on rewrite log by adding Apache directive "RewriteLogLevel 9" to the section of this vhost in your Apache httpd.conf. Send me the rewrite log and tell me which rewrite rule has been over processed along with the rewrite rules in your .htaccess files.
  7. aww

    aww New Member

    Okay here's the problem in how apache processes a certain rule differently than litespeed - it might be difficult for you to setup a test environment, though maybe you can do a quick wordpress install

    /~demosite has a blog installed in /~demosite/blog/

    To keep all the htaccess rules in the top-most directory, this is perfectly acceptable in apache

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /blog
    RewriteCond %{REQUEST_FILENAME} ^/home/demosite/public_html/blog/.*$
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /blog/index.php [L]
    </IfModule>

    However litespeed does not like this.
    For litespeed, these rules MUST be in .htaccess in /blog/ not /

    I have no idea why. But again, works in apache, not in litespeed

    This is what was messing up all the 404 error documents (except for the 404 "missing" which still does not work)

    Last but not least there is also a very minor issue in how litespeed treats:

    /~demosite/images/ as a 404 missing error, when it should be a 403 forbidden error because of -Indexes in a top-most .htaccess (or httpd.conf) This is trivial however compared to the other issue.
  8. aww

    aww New Member

    Per your debug log request for the blank 404 "missing"

    Code:
    2007-05-16 03:43:18.772 [DEBUG] [123.123.123.123:63893-0#APVH_server.example.net] New request: 
    	Method=[GET], URI=[/~demosite/fdgksdjfgsdfh5554],
    	QueryString=[]
    	Content Length=0
    2007-05-16 03:43:18.772 [DEBUG] [123.123.123.123:63893-0#APVH_server.example.net] Find context with URI: [/], location: [/usr/local/apache/htdocs/]
    2007-05-16 03:43:18.773 [DEBUG] [123.123.123.123:63893-0#APVH_server.example.net] redirect to: 
    	URI=[/fdgksdjfgsdfh5554],
    	QueryString=[]
    2007-05-16 03:43:18.773 [DEBUG] [123.123.123.123:63893-0#APVH_server.example.net] Find context with URI: [/], location: [/home/demosite/public_html/]
    2007-05-16 03:43:18.773 [DEBUG] [HTAccess] Updating configuration file [/home/demosite/public_html/.htaccess]
    2007-05-16 03:43:18.773 [INFO] [HTAccess] Updating configuration from [/home/demosite/public_html/.htaccess]
    2007-05-16 03:43:18.773 [DEBUG] [123.123.123.123:63893-0#APVH_server.example.net] Find .htaccess context with URI: [/], location: [/home/demosite/public_html/]
    2007-05-16 03:43:18.773 [DEBUG] [123.123.123.123:63893-0#APVH_server.example.net] File not found [/home/demosite/public_html/fdgksdjfgsdfh5554] 
    2007-05-16 03:43:18.773 [DEBUG] [123.123.123.123:63893-0#APVH_server.example.net] processContextPath() return 25
    2007-05-16 03:43:18.773 [DEBUG] [123.123.123.123:63893-0#APVH_server.example.net] processNewReq() return 25. 
    2007-05-16 03:43:18.773 [DEBUG] [123.123.123.123:63893-0#APVH_server.example.net] HttpConnection::sendHttpError(),code=404 Not Found
    2007-05-16 03:43:18.773 [DEBUG] [123.123.123.123:63893-0#APVH_server.example.net] HttpConnection::flush()!
    2007-05-16 03:43:18.773 [DEBUG] [123.123.123.123:63893-0#APVH_server.example.net] Written to client: 1373
    2007-05-16 03:43:18.773 [DEBUG] [123.123.123.123:63893-0#APVH_server.example.net] HttpConnection::nextRequest()!
    2007-05-16 03:43:22.111 [DEBUG] Failed to execute 'mpstat' command: No such file or directory 
    2007-05-16 03:43:23.772 [DEBUG] [123.123.123.123:63893-1] Keep-alive timeout, close!
    2007-05-16 03:43:23.772 [DEBUG] [123.123.123.123:63893-1] Close socket ...
    2007-05-16 03:43:27.117 [DEBUG] Failed to execute 'mpstat' command: No such file or directory 
    2007-05-16 03:43:32.120 [DEBUG] Failed to execute 'mpstat' command: No such file or directory 
    
    Last edited: May 16, 2007
  9. aww

    aww New Member

    LiteSpeed supports the QSA option on rewrites, correct?
  10. mistwang

    mistwang LiteSpeed Staff

    yes, it is implemented.
  11. aww

    aww New Member

    Was the debug log of any help at all?
  12. mistwang

    mistwang LiteSpeed Staff

    The log shows that the custom error page has been delivered.
    What browser are you using?
    Can you try somthing with "lynx"
    Code:
    lynx -mime_header http://....
    Please post the result.
  13. mistwang

    mistwang LiteSpeed Staff

    I built a 3.1.2 package for you with the fix to your rewrite rule. Just change the release number to 3.1.2 in the download link to get it.
    Thank you for raising this issue, our target is to make our rewrite engine 100% compatible with Apache's, no matter is better or worse.

    It is better to put all blog related rules under blog/ directory for better performance, the rewrite condition
    Code:
    RewriteCond %{REQUEST_FILENAME} ^/home/demosite/public_html/blog/.*$
    can be removed, and only requests to /blog/... will go through those rewrite rules. Just a recommendation.
  14. aww

    aww New Member

    Thank you for the quick fix. I will give this a test in about eight hours as I have to wait for server activity to go down.

    I assume you are able to reproduce this as I am dealing with a very complex set of rewrite rules and sometimes its hard to be sure they are all working at once without conflicting with each other and that it's not my own fault for a bad rule.

    It helps though that I am able to stop lsws and start httpd within a few seconds of each other to test compatibility however.

    On that note, keep in mind that apache DOES return the "missing" message on ErrorDocument with the same httpd.conf/htaccess however I will also give it a try with a raw browser tool I have like lynx - will post in a few minutes.
  15. aww

    aww New Member

    Response via litespeed:
    Code:
    05/16/07 13:53:04 Browsing http://example.net/blahblah123
    Fetching http://example.net/blahblah123 ...
    GET /blahblah123 HTTP/1.1
    
    Host: example.net
    
    Connection: close
    
    User-Agent: Mozilla/5.0 (WinNT)
    
    
    
    HTTP/1.1 404 Not Found
    
    Date: Wed, 16 May 2007 17:53:08 GMT
    
    Server: LiteSpeed
    
    Connection: close
    
    Content-Length: 8
    
    Content-Type: text/html
    
    response via apache:
    Code:
    05/16/07 13:57:03 Browsing 
    http://example.net/blahblah123
    Fetching http://example.net/blahblah123 ...
    GET /blahblah123 HTTP/1.1
    
    Host: example.net
    
    Connection: close
    
    User-Agent: Mozilla/5.0 (WinNT)
    
    
    
    HTTP/1.1 404 Not Found
    
    Date: Wed, 16 May 2007 17:57:03 GMT
    
    Server: Apache
    
    Connection: close
    
    Transfer-Encoding: chunked
    
    Content-Type: text/html; charset=iso-8859-1
    
    
    
    8  
    
    missing"
    
    0
    
    
    By the way, I have no idea what that 8 and 0 is before and after the apache ErrorDocument text is.

    Is it part of the "chunked encoded" process where it's a segment of sorts?
    Ah it might be the content-length for that segment of the chunked output.

    Apparently I also accidentally left an end quote on the the "missing" when it should be just "missing - but I doubt that is what is messing up lsws right?

    So is apache getting around the issue by using chunked output.
    I notice apache also appends a charset, though nothing is specified in my htaccess, must be in httpd or some kind of default. Is it not important for litespeed to mimic that behavior? Will litespeed obey if I add this to htaccess?
    AddDefaultCharset iso-8859-1
    Last edited: May 16, 2007
  16. aww

    aww New Member

    Last edited: May 16, 2007
  17. aww

    aww New Member

    Oh I just discovered something even worse with errordocument.
    Under a http 1.0 request it's not supported at all:

    Code:
    05/16/07 14:23:54 Browsing http://example.net/blahblah123
    Fetching http://example.net/blahblah123 ...
    GET /example.net/blahblah123 HTTP/1.0
    
    User-Agent: Mozilla/5.0 (WinNT)
    
    
    
    HTTP/1.0 404 Not Found
    
    Date: Wed, 16 May 2007 18:23:53 GMT
    
    Server: LiteSpeed
    
    Connection: close
    
    Cache-Control: private, no-cache, max-age=0
    
    Pragma: no-cache
    
    Content-Type: text/html
    
    Content-Length: 390
    
    
    
    <html>
    <head><title> 404 Not Found
    
    </title></head>
    <body><h1> 404 Not Found
    
    </h1>
    The resource requested could not be found on this server!<hr />
    Powered By <a href='http://www.litespeedtech.com'>LiteSpeed Web Server</a><br />
    <font face="Verdana, Arial, Helvetica" size=-1>Lite Speed Technologies is not responsible for administration and contents of this web site!</font></body></html>
    
  18. mistwang

    mistwang LiteSpeed Staff

    LSWS does not treat HTTP/1.0 or 1.1 differently on this matter. Have you changed any configuration?

    What testing tool are you using?
    You should redirect the result to a file, as the last line of LiteSpeed output is too short, just "missing", without "\n", so it was overwritten by the command line prompt. It is there, just not visible from command line.

    I think the issue you experienced is browser related. Have you tried it with other browsers?
  19. aww

    aww New Member

    I just tried the http 1.1 vs http 1.0 on the clean demosite account I had made under cpanel

    LiteSpeed is definitely returning it's default 404 error page under HTTP 1.0 when there is an ErrorDocument present in htaccess

    I will do a test with CURL to capture the exact http stream for 1.1 and 1.0

    I have tested this in IE/Firefox/Opera - all fail the errordocument.

    If you are getting different results on your test setup, then obviously this is a httpd.conf issue with the default cpanel setup I have, or possibly some option I have turned on inside LiteSpeed's config ?
  20. aww

    aww New Member

    Update, http 1.0 does work like 1.1 sorry about that.
    It's my stupid program that isn't handling the ~ correctly.


    But there is still an errordocument problem.

Share This Page