[英]Nginx Not finding static files
I'm trying to serve some static files (images) on nginx and I'm always getting 404.我正在尝试在 nginx 上提供一些静态文件(图像),但总是收到 404。
This is the url I'm testing:这是我正在测试的网址:
/uploads/test.png
/上传/测试.png
I have the folder with the images in:我有包含图像的文件夹:
/root/project/server/uploads
/root/项目/服务器/上传
This is my nginx configuration:这是我的 nginx 配置:
server {
listen 443 ssl default_server;
listen [::]:443 ssl default_server;
ssl_certificate /etc/ssl/certs/nginx-selfsigned.crt;
ssl_certificate_key /etc/ssl/private/nginx-selfsigned.key;
ssl_dhparam /etc/ssl/certs/dhparam.pem;
root /var/www/html;
index index.html index.htm index.nginx-debian.html;
server_name domain.com www.domain.com;
location ^~ /assets/ {
gzip_static on;
expires 12h;
add_header Cache-Control public;
}
location /uploads {
alias /root/trendcircle/server/uploads;
try_files $uri $uri/ =404;
autoindex on;
}
location /api {
proxy_http_version 1.1;
proxy_cache_bypass $http_upgrade;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Access-Control-Allow-Origin '*';
proxy_set_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, PUT, DELETE';
proxy_set_header 'Access-Control-Allow-Headers' 'X-Requested-With, Accept, Content-Type, Origin, x-access-token';
proxy_pass http://localhost:8080;
}
location / {
proxy_http_version 1.1;
proxy_cache_bypass $http_upgrade;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://localhost:8081;
}
}
Can some one help me?有人能帮我吗?
Thanks in advance!!提前致谢!!
The folder didn't have the same user as the user running nginx.该文件夹的用户与运行 nginx 的用户不同。 If it by executing this command:
如果通过执行此命令:
chmod o+x /root
chmod o+x /root
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.