Ssi Not Working On Default Page

Discussion in 'Apache' started by pnozzer, Feb 4, 2013.

  1. #1
    Hi,

    I'm new to this and have (for me, at least) a bit of a strange problem. I've set up SSI on my home apache2 server, adding some lines to /etc/apache2/apache2.conf (on Debian). The strange thing its working fine if I go to http://myip/index.html or http://myip/stuff.html, but when I go to just http://myip/ it doesn't include the text (the include command shows as a comment on the page source). I thought a request to http://myip/ just pulled the index.html file so am unsure what's going on... Might it have something to do with declaring the 'AddOutputFilter INCLUDES .html; AddType text/html .html;...' within a <Directory /var/www/*> tag in the conf file?

    Any help greatly appreciated
    Phil
     
    pnozzer, Feb 4, 2013 IP
  2. pnozzer

    pnozzer Peon

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #2
    Just so you know what's happening, here's the site: http://86.7.112.192/ which doesn't parse the includes, and http://86.7.112.192/index.html which does.
     
    pnozzer, Feb 4, 2013 IP
  3. joebert

    joebert Well-Known Member

    Messages:
    2,150
    Likes Received:
    88
    Best Answers:
    0
    Trophy Points:
    145
    #3
    My guess is that since the URI doesn't include the .html extension, AddOutputFilter doesn't get triggered for the request.

    What happens if you replace addoutputfilter with addoutputfilterbytype? XBitHack seems to parse SSI directives when a directory is requested instead of the filename.
     
    joebert, Feb 4, 2013 IP
  4. pnozzer

    pnozzer Peon

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #4
    Hi, thanks for getting back to me. addoutputfilterbytype doesn't produce any different results, and declaring 'XBitHack on' and commenting out the handlers etc (and then $ chmod +x index.html) doesn't produce different behaviour either. I'm out of ideas for this now...
     
    pnozzer, Feb 5, 2013 IP
  5. ryan_uk

    ryan_uk Illustrious Member

    Messages:
    3,983
    Likes Received:
    1,022
    Best Answers:
    33
    Trophy Points:
    465
    #5
    What's the actual config you have? I know you wrote it above, but I am guessing it's not exactly like that in your Apache config. Maybe something a bit wrong in it (even the order).

    Also, do you definitely not have index.htm or index.shtml (or similar) as well?
     
    ryan_uk, Feb 5, 2013 IP
  6. pnozzer

    pnozzer Peon

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #6
    Thanks for getting back. I definitely don't have other file types (only have 5 files in the www folder!). I can post the config when I get home. Strange how it would effect one url format but not the others though, seems like joebert might be onto something. Posted the q on serverfault.com got this response: My guess: the first format 86.7.112.192 becomes GET /, it does not contain .html ending, thus it's not parsed for SSI.
     
    pnozzer, Feb 5, 2013 IP
  7. ryan_uk

    ryan_uk Illustrious Member

    Messages:
    3,983
    Likes Received:
    1,022
    Best Answers:
    33
    Trophy Points:
    465
    #7
    That shouldn't happen (although I admit it's quite a few years ago that I used SSI), your DirectoryIndex is still .html. It seems more like an Apache configuration problem. Have you checked the server logs?
     
    ryan_uk, Feb 5, 2013 IP
  8. joebert

    joebert Well-Known Member

    Messages:
    2,150
    Likes Received:
    88
    Best Answers:
    0
    Trophy Points:
    145
    #8
    Interesting. I've got Apache setup to use XBitHack on an index.html, and in my case it's parsing the SSI whether I access index.html or just /

    Maybe a silly question, but you did remember to reload/restart Apache after updating your conf right?
     
    joebert, Feb 5, 2013 IP
    ryan_uk likes this.
  9. pnozzer

    pnozzer Peon

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #9
    Yep, I've been restarting (no such thing as a silly question with something like this!). I've put links to the the conf file and the access log here: http://86.7.112.192/stuff.html. One thing i noticed on the access log, is that when i make a request to / it doesn't show up on there (?). I also tried a simple rewrite rule of the form RewriteRule http://86.7.112.192/ http://86.7.112.192/index.html which didn't work (it did do a rewrite and reroute when i appended stuff.html to the first argument, so mod_rewrite is working). Thanks for your help on this, am learning a lot because of this problem :). I haven't touched anything in the conf file apart from changing loglevel to debug and adding the #ssi section at the end, so have no idea why yours, joebert, is running fine and mine isn't, very strange
     
    pnozzer, Feb 5, 2013 IP
  10. joebert

    joebert Well-Known Member

    Messages:
    2,150
    Likes Received:
    88
    Best Answers:
    0
    Trophy Points:
    145
    #10
    It's kind of interesting that there's different headers being sent with the different URLs.

    http://86.7.112.192/
    HTTP/1.1 200 OK
    Date:Wed, 06 Feb 2013 00:08:26 GMT
    Server:Apache/2.2.22 (Debian)
    Last-Modified:Tue, 05 Feb 2013 10:05:29 GMT
    ETag:"202e8-10c-4d4f7596a6c40"
    Accept-Ranges:bytes
    Content-Length:268
    Vary:Accept-Encoding
    Connection:close
    Content-Type: text/html
    Code (markup):
    http://86.7.112.192/index.html
    HTTP/1.1 200 OK
    Date:Wed, 06 Feb 2013 00:08:27 GMT
    Server:Apache/2.2.22 (Debian)
    Accept-Ranges:bytes
    Vary:Accept-Encoding
    Connection:close
    Content-Type: text/html
    Code (markup):
    It's as if the server is returning a different page altogether.
     
    joebert, Feb 5, 2013 IP
  11. ryan_uk

    ryan_uk Illustrious Member

    Messages:
    3,983
    Likes Received:
    1,022
    Best Answers:
    33
    Trophy Points:
    465
    #11
    Those different headers are due to caching.
     
    ryan_uk, Feb 5, 2013 IP
  12. ryan_uk

    ryan_uk Illustrious Member

    Messages:
    3,983
    Likes Received:
    1,022
    Best Answers:
    33
    Trophy Points:
    465
    #12

    1. What do the logs (error, not access) show for a request with and without index.html?
    2. What additions did you make to .htaccess?
     
    ryan_uk, Feb 5, 2013 IP
  13. pnozzer

    pnozzer Peon

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #13
    error.log has nothing for either / or /index.html, and I don't have an .htaccess file, have just added the section in apache2.conf. When i try to use a .htaccess (by shifting the directives from apache2.conf that i added) it doesn't work, which is also weird. Am thinking it might be less hassle to do a fresh install at this point?!
     
    pnozzer, Feb 6, 2013 IP
  14. ryan_uk

    ryan_uk Illustrious Member

    Messages:
    3,983
    Likes Received:
    1,022
    Best Answers:
    33
    Trophy Points:
    465
    #14
    Instead of:

    <!--#include file="shared.txt" -->
    Code (markup):
    Try:

    <!--#include virtual="/shared.txt" -->
    Code (markup):
    (Or /path/to/shared.txt instead.)
     
    ryan_uk, Feb 6, 2013 IP
  15. pnozzer

    pnozzer Peon

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #15
    Thanks for the suggestion, but that doesn't make a difference either (I get an error shown on the pages when using the full path, but virtual = "/shared.txt" gives the same result. Thanks for your help here, but I think I'm going to start again, I might have done something silly early on, who knows... Again, thanks a ton for the help, has taught me a lot. Cheers. P
     
    pnozzer, Feb 6, 2013 IP
  16. ryan_uk

    ryan_uk Illustrious Member

    Messages:
    3,983
    Likes Received:
    1,022
    Best Answers:
    33
    Trophy Points:
    465
    #16
    Have you tried going the "traditional" route and tested this naming the html files (and included file) as .shtml? It will mean some additional settings, but these are documented on the Apache help pages:
    http://httpd.apache.org/docs/current/mod/mod_include.html

    Establish whether this works, or not. It will help narrow down the problem.

    Oops, of course the literal path for virtual wouldn't have worked as it would have tried to use it as an URL.
     
    ryan_uk, Feb 7, 2013 IP
  17. cesurasean

    cesurasean Active Member

    Messages:
    269
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    80
    #17
    set your default document in apache's configs.
     
    cesurasean, Feb 19, 2013 IP