Solution: nginx static file access in centos7 is less than 403.
Today, we finally have time to solve the problem of configuring static files in nginx. The first problem encountered is that the static file access path is configured through nginx, but 403 occurs during access.
Environment: centos7 + nginx1.12.2.
The nginx. conf configuration file is as follows:
User nginx; worker_processes 1 ;.... # include/etc/nginx/conf. d /*. conf; # Set the server Load balancer instance list upstream tomcatgroup {# backend server access rules # ip_hash; # The weight parameter indicates the weight value. The higher the weight value, the higher the probability of being allocated. # PC_Local server 127.0.0.1: 8080 weight = 5; # PC_Server} server {listen 80; # Set the external port server_name 120.78.xxx.XXX; # Set the location of the recognition request domain name ~ \. (Png | jpg | gif) $ {root/data/wwwroot/;} location ~ \. (Css | js) $ {root/data/wwwroot/ROOT;} location/{root/data/wwwroot/ROOT; index. jsp; proxy_pass http: // tomcatgroup ;}}}
If I convert the static file to tomcat for processing, I can access it.
At first, I thought it was a path problem. I found a lot of examples on the Internet. Later, we found that there was a line of user nginx at the top. Look for the meaning of user. This is related to nginx. User indicates a user with the permission to the file.
Change nginx to root and restart nginx. It's a pleasure to visit ~~~~
The final conclusion is to add the user root in the header;
Cause: this problem is caused by unfamiliar nginx configuration files.
Learn about the nginx configuration file.
user root;....