How to prevent nginx from locking files on mounted samba partition in Centos 6

Posted by Bruce Kirkpatrick on Server Fault See other posts from Server Fault or by Bruce Kirkpatrick
Published on 2012-11-21T19:26:41Z Indexed on 2012/11/22 5:02 UTC
Read the original article Hit count: 448

I'm using nginx 1.3.8 inside a centos 6.3 virtualbox 4.2.4 virtual machine. The system is running the latest software available via yum update. The host OS is windows 7. The site files nginx is serving are on mounted samba partition, which is a folder on the host Windows system.

I.e., inside linux, nginx paths are referring to /home/vhosts and this is mounted from D:\vhosts\ on windows. The samba partition is mounted as root with 777 privileges. /etc/fstab looks like this, but with real ip, username, password:

//hostip/vhosts   /home/vhosts   cifs   username=username,password=SECRETPASSWORD,uid=root,gid=root,file_mode=0777,dir_mode=0777,rw,_netdev   0 0

I.e. linux/nginx reads from the windows share, and not the opposite.

in /etc/samba/smb.conf, I have tried to disable all samba locking features, but it seems to have no effect even after rebooting the virtual machine.

locking=no
share modes=no
oplocks = no
level2 oplocks = no
kernel oplocks =no

I'm receiving "Access is denied" errors in Windows or linux when attempting to overwrite the javascript file in windows that has been accessed at least once with nginx.

If I run "service nginx reload", the lock is removed and I'm able to save the file. That's why I think it is nginx causing the lock.

The same problem occurs with directories. However, that may be a different issue not related to the use of samba.

I'm using samba so that I can manage the source code outside of the virtual machine.

Also note that after I run "service nginx reload", the file I'm editing is actually automatically deleted from the windows host.

SOLVED: I just reviewed my nginx.conf file. It appears the "open_file_cache" feature is what is causing the lock and deleted files. When I set this option to open_file_cache off;, My problem is resolved. I will repost as the answer when it allows me to do so.

© Server Fault or respective owner

Related posts about Windows

Related posts about nginx