python - nginx为什么不能反代图片?

 小洲相册居士 发布于 2022-10-30 17:52

我的nginx配置

    location ^~ /images/ {
        alias /home/honmaple/storage/images/;
        expires 1d;
    }
    location ~* ^/admin/(.*)/static/ {
        alias /home/honmaple/.virtualenvs/blog/lib/python3.4/site-packages/flask_admin/static/;
        access_log off;
        expires 1d;
    }
    location ~ ^/(api|admin)/ {
        proxy_pass http://127.0.0.1:8001;
        proxy_redirect     off;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
    location / {
        return 403;
    }

图片路径类似这样 xxx.com/images/admin/thumb/2017/03/148941736894194.png

但是直接访问url会变成xxx.com/images/admin/thumb/2017/03/148941736894194.png/,
多了一个斜杠,并且报错404,
查看日志,发现是这样

2017/03/14 00:26:05 [error] 2288#2288: *15061 "/home/honmaple/storage/images/admin/thumb/2017/03/148941736894194.png/index.html" is not found (2: No such file or directory), client: 1.1.1.1, server: xxx.com, request: "GET /images/admin/thumb/2017/03/148941736894194.png/ HTTP/1.1", host: "xxx.com"

请教一下这是哪里的配置有问题

1 个回答
  • 你的这里写错了吧,location ^~ /images/ 不应该是~ ^吗

    2022-10-31 22:03 回答
撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有