5 使用docker部署发现静态文件全都404,求大佬给点建议

3个容器分别装nginx,mysql,和php运行环境,

访问首页能看到内容,但是css、js、图片全都404了

php环境的日志如下:

72.18.0.4 -  04/Sep/2020:07:15:49 +0000 "GET /index.php" 200

172.18.0.4 -  04/Sep/2020:07:15:50 +0000 "GET /index.php" 404

172.18.0.4 -  04/Sep/2020:07:15:50 +0000 "GET /index.php" 404

172.18.0.4 -  04/Sep/2020:07:15:50 +0000 "GET /index.php" 404

172.18.0.4 -  04/Sep/2020:07:15:50 +0000 "GET /index.php" 404

172.18.0.4 -  04/Sep/2020:07:15:50 +0000 "GET /index.php" 404

172.18.0.4 -  04/Sep/2020:07:15:50 +0000 "GET /index.php" 404

本人是php小白,为什么nginx过来的静态文件请求被nginx全都转成index.php了?

感觉应该是nginx的配置问题,但是conf文件是按照作者大大的教程抄来的,如下:

upstream demo.tipask2.cc {
    server 172.18.0.4:80;
}

server {
    listen  80;
    server_name  demo.tipask2.cc; #配置的站点域名,根据实际域名自行调整
    set $domain public;
    set $project_root /var/www/html;
    
    charset utf-8;
    #access_log  /home/wwwroot/tipask/storage/tipask.access.log combined; #需要查看访问日志的可以去掉注释
    #error_log   /home/wwwroot/tipask/storage/tipask.error.log error;#需要查看错误日志的可以去掉注释
    if (!-e $request_filename){
        rewrite ^/(.*)$ /index.php?$1 last;
    }
    
    location / {
        root $project_root/$domain;
        index  index.php index.html;
        try_files $uri $uri/ /index.php$is_args$query_string;
    }
    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }
    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    location ~ \.php$ {
        fastcgi_pass   tipask-app:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $project_root/$domain$fastcgi_script_name;
        include        fastcgi_params;
    }
}
求高手给点建议,可能是什么原因
请先 登录 后评论

最佳答案 2020-09-12 10:00

配置文件有问题,你按照下面的这个教程里面的配合文件来配置看下。

https://wenda.tipask.com/article/14350

请先 登录 后评论

其它 0 个回答

  • 3 关注
  • 0 收藏,3929 浏览
  • cuicuifly 提出于 2020-09-04 15:26