September 23, 2016
If not the browser then what?
Okay, the static files served by Nginx are first accessed by the guest OS through a VirtualBox shared folder. As per a very old «bug» it seems that the sendfile() function (enabled in Nginx) is not very friendly with the shared folder feature of VirtualBox Guest Additions.
While some people have resorted to using NFS for sharing files between host & guest machines; a quicker workaround is to turn off sendfile in Nginx.
Put the above inside the http block to apply to all your virtual hosts or just within the concerned vhost’s server block.
The sendfile() system call in the Linux kernel allows data to be copied from one file descriptor to another file descriptor; unlike traditionally requiring more system calls for reading and writing. It is actually well documented at tdlp.org.
Disabling sendfile has a performance downside but let’s just say it is acceptable for the local development environment.