Bootstrap(Laravel) assets 404-error from Docker(Nginx)

拜拜、爱过 提交于 2020-12-15 03:51:31

问题


The goal:

Make newly created Laravel6 projects' bootstrap assets layout work from Docker.

Symptoms: Bootstrap assets work properly on local Laravel development environment (XAMPP -Apache- +Win10Pro), both the js and css are loaded well. But does'not work properly from local Docker (Win10-linux containers, Nginx+PHP+MySql+Redis), app.js and app.css runs on error 404.

Apache(local xampp):

Nginx(Docker):

What I did:

  • New Laravel project created, auth added, bootstrap, npm and node installed properly.
  • Virtual Host settings (httpd-vhosts.conf) for Apache in xampp:

    • nginx.conf in nginx container

  • Virtual Host settings (default.conf) for Nginx in nginx container:

  • .htaccess file in my projectfolder /a_new_app_for_test/public/

  • docker-compose.yml for nginx

  • docker-compose.yml for app

What settings should I add/change in order to make assets loaded correctly?

I suppose it could be related to nginx settings compiled into Docker.

Any help are appreciated.

Thanks in advance.


回答1:


Try to copy your whole project to the container volume, this way nginx will be able to see your files from public or resources folder.

volumes:
  - ./:/var/www/


来源:https://stackoverflow.com/questions/61271923/bootstraplaravel-assets-404-error-from-dockernginx

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!