nginx访问静态资源文件,未指定静态资源的名称怎么办

2025-04-28 07:01:47
推荐回答(1个)
回答1:

今天在搭建nginx环境时出现一个奇怪问题,配置的静态资源目录下面文件无法访问,浏览器访问出现403 forbidden,环境是centos7 + nginx 1.6。nginx.conf中http配置如下:

[plain] view plain copy
……

http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;

upstream tomcat_server {
server 10.10.100.52:8080;
}

server {
listen 80;
charset utf-8;
server_name localhost;

location /fcm/ {
index index.html index.htm;
proxy_pass http://tomcat_server;
proxy_set_header X-Real-IP $remote_addr;
client_max_body_size 100m;
}

location /static/ {
root /home/www/static;
}

error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}