dtsc1684 2017-03-13 11:53
浏览 63
已采纳

laravel图像干预的nginx 404错误

Currently, I'm getting an error that the laravel image intervention package always return 404 error every time I try to access an image via URL manipulation.

My images are stored in 'storage/app/images' folder

My nginx config:

    server {
    listen   80;

    server_name ######;
    rewrite ^(.*) http://#####$1 permanent;
    }server {
    listen   80;

    # access_log off;
    access_log /home/#####/logs/access.log;
    # error_log off;
    error_log /home/#####/logs/error.log;

    root /home/######/public_html/dtu-feedback-api/public;
    index index.php index.html index.htm;
    server_name ######;

    # Custom configuration
    include /home/######/public_html/dtu-feedback-api/*.conf;

    location / {
            try_files $uri $uri/ /index.php?$query_string;
    }
    if (!-d $request_filename) {
            rewrite     ^/(.+)/$ /$1 permanent;
    }

    location ~ \.php$ {
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            include /etc/nginx/fastcgi_params;
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_index index.php;
            fastcgi_connect_timeout 300;
            fastcgi_send_timeout 300;
            fastcgi_read_timeout 300;
            fastcgi_buffer_size 32k;
            fastcgi_buffers 8 16k;
            fastcgi_busy_buffers_size 32k;
            fastcgi_temp_file_write_size 32k;
            fastcgi_intercept_errors on;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }
    location ~ /\. {
            deny all;
    }
    location = /favicon.ico {
            log_not_found off;
            access_log off;
    }
    location = /robots.txt {
            allow all;
            log_not_found off;
            access_log off;
    }
    location ~* \.(3gp|gif|jpg|jpeg|png|ico|wmv|avi|asf|asx|mpg|mpeg|mp4|pls|mp3|mid|wav|swf|flv|exe|zip|tar|rar|gz|tgz|bz2|uha|7z|doc|docx|xls|xlsx|pdf|iso|eot|svg|ttf|woff)$ {
            gzip_static off;
            add_header Pragma public;
            add_header Cache-Control "public, must-revalidate, proxy-revalidate";
            access_log off;
            expires 30d;
            break;
    }

    location ~* \.(txt|js|css)$ {
            add_header Pragma public;
            add_header Cache-Control "public, must-revalidate, proxy-revalidate";
            access_log off;
            expires 30d;
            break;
    }
}

And here is the log:

*1 open() "/home/#####/public_html/dtu-feedback-api/public/imagecache/medium/placeholder1.png" failed (2: No such file or directory)

Look like it tried to find the images in the imagecache path instead of the storage path.

So could you please help me with this error, thank you.

  • 写回答

1条回答 默认 最新

  • duanjiaoxi4928 2017-03-13 13:02
    关注

    I found the solution, after I remove the

    location ~* \.(3gp|gif|jpg|jpeg|png|ico|wmv|avi|asf|asx|mpg|mpeg|mp4|pls|mp3|mid|wav|swf|flv|exe|zip|tar|rar|gz|tgz|bz2|uha|7z|doc|docx|xls|xlsx|pdf|iso|eot|svg|ttf|woff)$ {
                gzip_static off;
                add_header Pragma public;
                add_header Cache-Control "public, must-revalidate, proxy-revalidate";
                access_log off;
                expires 30d;
                break;
        }
    

    Then the image link starts working

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)
  • ¥15 AIC3204的示例代码有吗,想用AIC3204测量血氧,找不到相关的代码。