python - nginx為什么不能反代圖片?
問題描述
我的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/ 不應該是~ ^嗎
相關文章:
1. Docker for Mac 創建的dnsmasq容器連不上/不工作的問題2. javascript - 求賜教:網易郵箱Web端模擬登錄看信的加密參數_ntes_nnid、_ntes_nuid3. javascript - 使用angular 的ui-sref 中出現了中文參數,點擊跳轉后瀏覽器的地址欄里出現轉義后的%AE....%a%44. java - ConcurrentHashMap中的get()方法為什么可以不加鎖?5. javascript - QWebEngineView 如何爬 angular 的動態數據?6. html5 - 這個代碼顯示功能如何實現?7. javascript - 用JS 七牛上傳圖片出現文件已存在的錯誤(file exists)8. 工作近5年,3年Java Web ,近2年前端,未來何去何從?9. css3 - 圖片等比例縮放10. java - 字節流轉成字符串之后,在通過字符串轉成字節流后的文件為什么會不一樣?
