Solution: nginx static file access in centos7 is less than 403.

Source: Internet
Author: User

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;....

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.