Javascript - ERR_CONTENT_LENGTH_MISMATCH

后端 未结 8 924
广开言路
广开言路 2020-12-02 19:58

I\'m making a basic jquery playground site. I am getting Error: net::ERR_CONTENT_LENGTH_MISMATCH is happening on page load and the background images are not loa

8条回答
  •  离开以前
    2020-12-02 20:32

    Summary

    Here is a more detailed explanation of what happened in my case. The selected answer here helped me solve my problem and this is basically a more detailed version of the selected answer on hows and whys!

    Explaining Nginx Permissions

    You can run nginx as a nobody user and that is the common practice in most sample configs. You will find this line at the top of your config:

    user nobody;
    

    It is however suggested that for your web-apps static contents, such as css, js, and image files to allow nginx access and cash it through bypassing your web-app
    container. This the part of your config where it reads:

    location ^~ /static {
        alias /path/to/your/static/folder/;
        autoindex on;
        expires max;    
    }
    

    This is the folder nginx needs to have access to.

    On the other hand, there is nginx dedicated folder where in the above answer's case was in:

    /usr/local/var/run/nginx/
    

    In my case (CentOS) it was in:

    /var/lib/nginx/
    

    How can things go wrong?

    In either of these cases you can break nginx:

    1- Nginx runs as nobody but doesn't have the right access to your static folder.

    2- Nginx runs as nobody but then runs as root to gain access to your static folder.

    Solution

    Best solution in my case was to change the permission of the nginx dedicated folder to match with my static folder. And then run nginx with as a user with the right access to both.

提交回复
热议问题