NGINX css problems

Issue #70 resolved
Chris Hird created an issue

Problem with NGINX running on IBM i where css is not correctly set.

I have a page which has the following to include the css

<link rel="stylesheet" href="css/gen.css" type="text/css">

The content (not full content) for the file is

/*
Copyright 2019, Shield Advanced Solutions Ltd
All rights reserved.
http://www.shieldadvanced.com/

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:

  • Redistributions of source code must retain the above copyright
    notice, this list of conditions and the following disclaimer.
  • Neither the name of the Shield Advanced Solutions, nor the names of its
    contributors may be used to endorse or promote products
    derived from this software without specific prior written
    permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
/
/

Created on : 14-Aug-2019, 2:01:22 PM
Author : Chris Hird Shield Advanced Solutions Ltd.>
*/

.clear {
clear: both;
}

However when the page is displayed I get no css definitions, I checked the errors in the console and I see the following.

The stylesheet http://ha4i73.shield.local/css/gen.css was not loaded because its MIME type, “text/plain”, is not “text/css”. ha4i73.shield.local

I checked the mime types configuration in /etc/nginx/mime.types and there is a text/css css; entry.

If I re-open the page and select the inspect option within firefox (where I can see the errors in the console) I then also see the following for the very first time I open the inspect page.

Stylesheets without CSSOM changes reparsed to check for errors. Refresh the page to also see errors from stylesheets changed from CSSOM and from style attributes.

This only happens on the new NGINX install in IBM i, I am running the exact same set up on Linux without any problems.

Comments (7)

  1. Kevin Adler

    That’s interesting. We’re just shipping the upstream mime.types from NGINX. I would have thought they’d have css in there. I will look in to it.

  2. Chris Hird reporter

    There are other issues as well! I removed all of the comments from all of the files (I have license headers etc as comments) and the CSS works but only after the reparse (as per the message above!) has been carried out. In addition to this I have a problem with the php session_start() process. It states that it cannot run because the headers have already been sent??? Its only comments that are before it so I think this has something to do with it as well? Same code all runs without any problems on the Linux Test boxes we have, so I am assuming this is an IBM i based problem? Lots of issues at the moment it appears.

  3. Chris Hird reporter

    Kevin, if you need me to set up some tests and send in the results happy to do so. I am busy creating an exact environment on both Linux (x86 only) and IBM i so I can verify what happens on each system when running the exact same code. Will take me a couple of days to get a couple of clean setups but it may help figure out what is going on?

  4. Chris Hird reporter

    Kevin, I have made a simple change so that the css file just has a comment at the top. If I do that the problem above occurs (seens as text/plain not test/css which it should be). I created an exact copy of the environment on Linux which is running

    NGINX 1.10.3

    php-fpm PHP 7.3.3-1+0~20190307202245.32+stretch~1.gbp32ebb2 (cli) (built: Mar 7 2019 20:22:46) ( NTS ) Copyright (c) 1997-2018 The PHP Group Zend Engine v3.3.3, Copyright (c) 1998-2018 Zend Technologies with Zend OPcache v7.3.3-1+0~20190307202245.32+stretch~1.gbp32ebb2, Copyright (c) 1999-2018, by Zend Technologies

    This is the setup on the IBM i 7.4 system

    NGINX 1.15.2 with php-fpm

    PHP 7.3.6 (cli) (built: Jul 19 2019 18:03:25) ( NTS )
    Copyright (c) 1997-2018 The PHP Group
    Zend Engine v3.3.6, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.3.6, Copyright (c) 1999-2018, by Zend Technologies

    The page is index.php so I assume it is being processed through the php interpreter which may be where the problem is? I will also do some testing with a simple html file and css.

  5. Chris Hird reporter

    Any idea when this will be resolved? I have a number of other issues associated with php-fpm which may or may not be related to this issue?

  6. Kevin Adler

    Hey Chris, I’ve been very busy with other things recently, but we ran in to a similar issue today and solved it by adding include /QOpenSys/etc/nginx/mime.types; in your http section.

    eg.

    http {
        default_type  application/octet-stream;
        include /QOpenSys/etc/nginx/mime.types;
    
        # ...
    }
    

  7. Jesse G

    Closing with the assumption that /QOpenSys/etc/nginx/mime.types resolves the issue. Feel free to reopen if not the case.

  8. Log in to comment