douji1853 2019-04-01 11:55
浏览 157

使用带有nginx和docker-compose的Laravel找不到图像

This is basically an extension on my question here. I have now added the permissions on storage folder and I do not get the 500 error anymore. But now I get 404 instead.

  • The image URL I'm trying is URL: http://localhost:8888/images/content/test/myimage.jpg
  • The server path to the image is /var/www/public/images/content/test/myimage.jpg

My nginx-config is the following:

user  nginx;
worker_processes  2;
error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;
worker_rlimit_nofile 100000;
events {
    worker_connections  2048;
}
http {
    include /etc/nginx/mime.types;
    default_type application/octet-stream;
    log_format main '$remote_addr - $remote_user [$time_local] "$request" '
                    '$status $body_bytes_sent "$http_referer" '
                    '"$http_user_agent" "$http_x_forwarded_for"';
    access_log /var/log/nginx/access.log  main;
    sendfile on;
    tcp_nopush on;
    keepalive_timeout 65;
    gzip on;
    server {
      listen  8888;
      root /var/www/public;
      index index.php index.html index.htm;
      client_max_body_size 100m;
      location / {
          try_files $uri $uri/ /index.php?$query_string;
      }
      location ~ ^/.+\.php(/|$) {
          fastcgi_pass app:9000;
          include fastcgi_params;
          fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
      }
    }
}

My guess is that it's something wrong with the config above but I have no idea what it might be. I have tried the solution suggested here but it did not do any difference at all.

Does anyone have any idea what to do?

  • 写回答

1条回答 默认 最新

  • duane2364 2019-04-01 12:07
    关注

    It might be the path in this line: location ~ ^/.+\.php(/|$)

    Try it like this:

    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
    
    评论

报告相同问题?

悬赏问题

  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)
  • ¥15 AIC3204的示例代码有吗,想用AIC3204测量血氧,找不到相关的代码。
  • ¥20 CST怎么把天线放在座椅环境中并仿真
  • ¥15 任务A:大数据平台搭建(容器环境)怎么做呢?