Results 1 to 5 of 5

Thread: [Apache2] "Content-type not text" error, but it's text/html

  1. #1
    Join Date
    Aug 2017
    Beans
    178

    [Apache2] "Content-type not text" error, but it's text/html

    If this is an inappropriate question feel free to delete. Just moved my wife's old legacy site to a new VPS server on almaLinux running cPanel/WHM. I haven't done a lot of customization, things just seem to work except this.

    The problem: getting a content-type error from Apache2 when I know the output of this script includes content type headers.

    Code:
    [Thu Dec 21 10:59:34.717822 2023] [include:error] [pid 738483:tid 23353639089920] [client (ip address)] unable to include potential exec "/cgi-bin/articles_menu.cgi?c=name-of-the-page" in parsed file /home/(user)/public_html/name-of-the-page.shtml, content type not text/*, referer: https://www.(user).com/
    Starts here:

    Code:
    <!--#include virtual="/cgi-bin/articles_menu.cgi?c=name-of-the-page" -->
    The script is extremely simple and it works, and has for years, depending on what page you're on it opens and parses a plain text file and skips "name of the page" before outputting the menu like so:

    Code:
     if ($ENV{'QUERY_STRING'}) {
       print "content-type: text/html\n\n";
       print "$out";
     }
    As mentioned I've confirmed this works via cli and you can request the URL from a browser like
    Code:
    aitch-tee-tee-pea-ess//example.com/cgi-bin/articles_menu.cgi?c=name-of-the-page
    When you request that URL, FF Inspector says the output headers are content-type text/html.

    I have confirmed indeed $out is populated and working. Appropriate handlers are operational. Both SSI's and scripts are working fine. Reviewed the Apache docs and not seeing anything relevant.

    Am I missing an Apache config that addresses "potential exec?" (I doubt that's the problem but . . . ) Does anyone have any ideas where I could look?

    A few specs:

    cPanel Version 116.0 (build 7)
    Apache Version 2.4.58
    Perl Version 5.26.3

    User Defined Apache Handlers
    application/x-httpd-ea-php74 .php .php7 .phtml (This site is pre-PHP, that's how old school it is)
    server-parsed .html
    server-parsed .shtml .html

    System Apache Handlers
    cgi-script .cgi .pl .plx .ppl .perl
    server-parsed .shtml

  2. #2
    Join Date
    Oct 2006
    Beans
    58,286

    Re: [Apache2] "Content-type not text" error, but it's text/html

    Thread moved to the "Any Other OS! forum

  3. #3
    Join Date
    Aug 2017
    Beans
    178

    Re: [Apache2] "Content-type not text" error, but it's text/html

    Quote Originally Posted by howefield View Post
    Thread moved to the "Any Other OS! forum
    Thank you, I did a search and found some other posts in programming.

  4. #4
    Join Date
    Aug 2017
    Beans
    178

    Re: [Apache2] "Content-type not text" error, but it's text/html

    To anyone coming to this thread to solve the error . . .

    I experimented with a lot of stuff from both WHM and this user's cPanel, namely around the option IncludesNoExec. This really shouldn't have any effect because we're using include virtual, not include exec, but no matter - enabling that option only causes the server to ignore the include line (not parsiing the include, you see it in source code of the page as it is above.)

    What fixed it for me
    was to simply add Includes to the user's root .htaccess

    Code:
    Options +Includes
    I would have never thought to look there because any other SSI include that is plain text or html was included and parsed just fine.

    This is perfect if you don't want to mod the Apache httpd.conf (it warns at the top it could potentially be overwritten by cPanel.) But of course you do have to allow the user's directory to allow overrides.
    Last edited by sdsurfer; December 22nd, 2023 at 08:01 PM.

  5. #5
    Join Date
    Mar 2024
    Beans
    4

    Re: [Apache2] "Content-type not text" error, but it's text/html

    Hi sd surfer, thanks for the post, I had a:
    Content is not loading because its MIME type, "text/html" is not "text/css"

    Fixed it by deleting:
    [COLOR=var(--highlight-keyword)]if[/COLOR] (process.env.NODE_ENV == [COLOR=var(--highlight-variable)]'production'[/COLOR]) {
    app.[COLOR=var(--highlight-literal)]use[/COLOR](express.[COLOR=var(--highlight-literal)]static[/COLOR]([COLOR=var(--highlight-variable)]'client/build'[/COLOR]));
    }

    app.[COLOR=var(--highlight-literal)]get[/COLOR]([COLOR=var(--highlight-variable)]'*'[/COLOR], (req, res) => {
    res.[COLOR=var(--highlight-literal)]sendFile[/COLOR](path.[COLOR=var(--highlight-literal)]join[/COLOR](__dirname, [COLOR=var(--highlight-variable)]'client'[/COLOR], [COLOR=var(--highlight-variable)]'build'[/COLOR], [COLOR=var(--highlight-variable)]'index.html'[/COLOR]))
    });
    In the server.js file

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •