You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have been using nginx as reverse proxy for my daily development work. After upgrading nginx today, it somehow stops working correctly: a vendor.js file built from webpack has not been served properly. I get the following error from chrome console:
GET http://nginx.example.com/dist/js/vendor.js net::ERR_CONTENT_LENGTH_MISMATCH
I take some quick lookarounds and find out:
Network tab shows the vendor.js request has a status code 200.
The response header seems to be fine. However, there is nothing to preview in chrome network tab.
The Content-Length of the vendor.js matches the real size of the file.
# ls -l : get the size in byte
-rw-r--r-- 1 michaelzheng staff 4844863 Jul 2 17:00 vendor.js
# ls -lh : get the size in human readable format
-rw-r--r-- 1 michaelzheng staff 4.6M Jul vendor.js
Loading the vendor.js directly through browser or curl works perfectly.
Debug
Find the location of nginx config file(i.e. nginx.conf)
nginx -t
Find the location of error log, which is usually defined in nginx.conf
Background
I have been using nginx as reverse proxy for my daily development work. After upgrading nginx today, it somehow stops working correctly: a vendor.js file built from webpack has not been served properly. I get the following error from chrome console:
I take some quick lookarounds and find out:
The response header seems to be fine. However, there is nothing to preview in chrome network tab.
The Content-Length of the vendor.js matches the real size of the file.
curl
works perfectly.Debug
Find the location of nginx config file(i.e. nginx.conf)
Find the location of error log, which is usually defined in nginx.conf
Check out the error
Now that we can clearly see it's related to permission problem of the buffer directory
proxy_temp
.Solutions
Solution 1 - Grant permission
You need to first run the command
ps aux | grep nginx
to find out the owner of the nginx process which is usuallynobody
Solution 2 - Disable buffering with proxy_buffering set to
off
Solution 3 - Change the buffer directory to other directory the nginx process owner has permission to, with proxy_temp_path directive.
Notice
The text was updated successfully, but these errors were encountered: