首页 > 解决方案 > Nginx 配置为图像服务器,但得到 403 禁止错误

问题描述

我尝试将 nginx 配置为图像服务器,如下所示

创建 myapp.conf 并将其放在 /etc/nginx/conf.d

server {

    listen 80;

    listen [::]:80; 

     #here you could also use subdomain

    server_name image.mydomain.com ;

    #here you could also use context,e.g. location /<context>

    location / {

      root /myapp/imageServer/;

      autoindex on;

    }

}

该文件位于 /myapp/imageServer/card/3cdad37c5a394567b53283321f6af9e9.png

但是当我通过https://image.mydomain.com/card/3cdad37c5a394567b53283321f6af9e9.png浏览这个文件时。我从 nginx 得到了 403 禁止。我的 nginx 配置有什么错误吗?

标签: nginx-config

解决方案


我找到了原因

去 /etc/nginx/nginx.conf

编辑行如下

#user www-data;
user root;

推荐阅读