How to make the picture files uploaded by springmvc to Nginx automatically have readable permissions?

1. Describe that
uses springmvc to upload files to the / opt/upload/ [dir] / directory on the server, and tomcat and nginx are deployed on the same server.

1Tomcat uses tomcat to launch
clipboard.png

Nginxnginx:
clipboard.png


upload:


2.
nginx
nginx403 forbidden
clipboard.png

I can"t manually set its permissions every time I upload a picture.
how can I set up so that newly uploaded images have readable permissions automatically?


has been resolved. It has something to do with umask.
reason:
linux default umask is 022, corresponding permission is 755, other users can read and execute . You can search vim / etc/profile, for the umusk keyword to see

if [ $UID -gt 199 ] && [ "`/usr/bin/id -gn`" = "`/usr/bin/id -un`" ]; then
    umask 002
else
    umask 022
fi

while the default umask for tomcat8 is 027, and the corresponding permission for is 750, which means that other users do not even have readable permissions .
you can open the catalina.sh file and search umask for viewing.

-sharp Set UMASK unless it has been overridden
if [ -z "$UMASK" ]; then
    UMASK="0027"
fi
umask $UMASK

solution:
modify the umask in catalina.sh to 0022, consistent with the operating system, and then restart tomcat.

reference blog:
linux umask usage details .
from Tomcat version 8.0

Menu