nginx指向本地文件夹静态文件服务器

nginx指向本地文件夹静态文件服务器

修改nginx-1.17.3目录conf文件中nginx.conf配置文件

#配置跨域

    add_header Access-Control-Allow-Origin *;

    add_header Access-Control-Allow-Headers X-Requested-With;

    add_header Access-Control-Allow-Methods GET,POST,OPTIONS;

location / {

       #代理本地文件夹

        alias /usr/local/webserver/sharedFile/;

        autoindex on;

    }

重启nginx
注意尾部要加“/”不然会404!!!

/usr/local/webserver/nginx/sbin/nginx -s reopen

猜你喜欢

转载自blog.csdn.net/qq_33144515/article/details/105731122