50
Step over nginx buffer issue
source link: https://www.tuicool.com/articles/hit/UFVjUbY
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Step over nginx buffer issue
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:
GET http://nginx.example.com/dist/js/vendor.js net::ERR_CONTENT_LENGTH_MISMATCH
I take some quick lookarounds and find out:
# 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 curl
Debug
nginx -t # tail -f nginx 2018/07/02 22:29:27 [crit] 14586#0: *3641 open() "/usr/local/var/run/nginx/proxy_temp/1/08/0000000081" failed (13: Permission denied) while reading upstream, client: 127.0.0.1, server: nginx.example.com, request: "GET /dist/js/vendor.js HTTP/1.1", upstream: "http://127.0.0.1:8080/dist/js/vendor.js", host: "nginx.example.com", referrer: "http://nginx.example.com/testabc" proxy_temp
Solutions
- Solution 1 — Grant permission
-
chown -R nobody:admin proxy_temp
- 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
- If you want to follow the latest news/articles for the series of my blogs, Please 「Watch」 to Subscribe.
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK