API Platform version(s) affected: 1.2.1
Description
I'm working on a new project and just installed apiplatform on it (in total I have 2 projects, one for the app and one for the API only), all work but when I'm going at _/api/contacts_ (for example), I get the page without any css/scripts. If I look into the logs I can see an error 404 on all resources inside /bundles/apiplatform.
nginx_1 | 172.18.0.1 - - [03/Dec/2019:20:35:24 +0000] "GET /bundles/apiplatform/style.css HTTP/1.1" 404 37396 "http://api.simtp.local:8785/api" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:70.0) Gecko/20100101 Firefox/70.0"
Maybe an error in my nginx config but I passed the last 2 hours on this problem and I can't find the source of that problem.
Here is my docker-compose config:
version: '2'
services:
nginx:
image: 'bitnami/nginx:1.16'
ports:
- '8784:8080'
- '8785:8081'
networks:
- default
depends_on:
- phpfpm
volumes:
- './simtp/public/simtp.conf:/opt/bitnami/nginx/conf/server_blocks/simtp.conf:ro'
- './simtp_api/public/simtp_api.conf:/opt/bitnami/nginx/conf/server_blocks/simtp_api.conf:ro'
phpfpm:
image: 'bitnami/php-fpm:latest'
networks:
- default
volumes:
- './simtp:/app/simtp'
- './simtp_api:/app/simtp_api'
simtp:
image: 'bitnami/symfony:1'
ports:
- '8780:8000'
volumes:
- '.:/app'
environment:
- TZ=America/New_York
- SYMFONY_PROJECT_NAME=simtp
depends_on:
- simtp_api
- nginx
networks:
- default
simtp_api:
image: 'bitnami/symfony:1'
ports:
- '8782:8000'
volumes:
- '.:/app'
environment:
- TZ=America/New_York
- SYMFONY_PROJECT_NAME=simtp_api
- MYSQL_ROOT_USER=root
- MYSQL_ROOT_PASSWORD=
- MYSQL_USER=simtp01
- MYSQL_PASSWORD=*************
- MYSQL_DATABASE=simtp
- ALLOW_EMPTY_PASSWORD=yes
depends_on:
- mysqldb
- nginx
networks:
- default
mysqldb:
image: 'bitnami/mysql:5.7'
ports:
- '8783:3306'
volumes:
- './mysql-persistence/mysql/data:/bitnami/mysql/data'
environment:
- MYSQL_ROOT_USER=root
- MYSQL_ROOT_PASSWORD=
- MYSQL_USER=simtp01
- MYSQL_PASSWORD=*************
- MYSQL_DATABASE=simtp
- ALLOW_EMPTY_PASSWORD=yes
networks:
- default
networks:
default:
driver: bridge
And my conf file for nginx:
server {
server_name api.simtp.local;
root /app/simtp_api/public;
listen 0.0.0.0:8081;
location / {
# try to serve file directly, fallback to index.php
try_files $uri /index.php$is_args$args;
}
# optionally disable falling back to PHP script for the asset directories;
# nginx will return a 404 error when files are not found instead of passing the
# request to Symfony (improves performance but Symfony's 404 page is not displayed)
# location /bundles {
# try_files $uri =404;
# }
location ~ ^/index\.php(/|$) {
fastcgi_pass phpfpm:9000;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
# Increase the buffer size to handle large cache invalidation headers
fastcgi_buffer_size 32k;
fastcgi_buffers 32 4k;
# optionally set the value of the environment variables used in the application
# fastcgi_param APP_ENV prod;
# fastcgi_param APP_SECRET <app-secret-id>;
# fastcgi_param DATABASE_URL "mysql://db_user:db_pass@host:3306/db_name";
# When you are using symlinks to link the document root to the
# current version of your application, you should pass the real
# application path instead of the path to the symlink to PHP
# FPM.
# Otherwise, PHP's OPcache may not properly detect changes to
# your PHP files (see https://github.com/zendtech/ZendOptimizerPlus/issues/126
# for more information).
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT $document_root;
# Prevents URIs that include the front controller. This will 404:
# http://domain.tld/index.php/some-path
# Remove the internal directive to allow URIs like this
internal;
}
# return 404 for all other php files not matching the front controller
# this prevents access to other php files you don't want to be accessible.
location ~ \.php$ {
return 404;
}
}
If anyone can help me I'll be happy. Thanks!
I finally found the problem, forget to create the volumes in my nginx in docker-compose:
nginx:
image: 'bitnami/nginx:1.16'
ports:
- '8784:8080'
- '8785:8081'
networks:
- default
depends_on:
- phpfpm
volumes:
- './simtp/public/simtp.conf:/opt/bitnami/nginx/conf/server_blocks/simtp.conf:ro'
- './simtp_api/public/simtp_api.conf:/opt/bitnami/nginx/conf/server_blocks/simtp_api.conf:ro'
- './simtp:/app/simtp:ro' # ---- THIS LINE IS THE SOLUTION ----
- './simtp_api:/app/simtp_api:ro' # ---- THIS LINE IS THE SOLUTION ----
Most helpful comment
I finally found the problem, forget to create the volumes in my nginx in docker-compose: