I'm trying to deploy a Symfony application to Elastic Beanstalk but it looks like URL rewriting is not working.
Using platform PHP 7.4 running on 64bit Amazon Linux 2 and the document root is /public.
.platform/nginx/conf.d/nginx.conf
server {
listen 80;
root /var/app/current/public;
index index.php;
location / {
# try to serve file directly, fallback to index.php
try_files $uri /index.php$is_args$args;
}
location ~ ^/index\.php(/|$) {
#fastcgi_pass unix:/var/run/php-fpm.sock;
fastcgi_pass php-fpm;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
#include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT $realpath_root;
}
access_log /var/log/nginx/access.log main;
client_header_timeout 60;
client_body_timeout 60;
keepalive_timeout 60;
gzip off;
gzip_comp_level 4;
# Include the Elastic Beanstalk generated locations
#include conf.d/elasticbeanstalk/*.conf;
}
But server cannot find the path for domain.com/auth/login (but works for domain.com/index.php/auth/login
----------------------------------------
/var/log/nginx/error.log
----------------------------------------
2020/05/16 17:32:48 [warn] 3709#0: conflicting server name "" on 0.0.0.0:80, ignored
2020/05/16 17:32:48 [warn] 3736#0: conflicting server name "" on 0.0.0.0:80, ignored
2020/05/16 17:32:48 [warn] 3740#0: conflicting server name "" on 0.0.0.0:80, ignored
2020/05/16 17:33:29 [error] 3744#0: *2 open() "/var/www/html/public/auth/login" failed (2: No such file or directory), client: 172.31.42.4, server: , request: "GET /auth/login HTTP/1.1", host: "..."
If I remove the comment mark (#) for fastcgi_params, it's failing to find it.
I found an interesting 'Error' in /var/log/eb-engine.log:
2020/05/16 18:21:37.054548 [INFO] Running command /bin/sh -c /usr/sbin/nginx -t -c /var/proxy/staging/nginx/nginx.conf
2020/05/16 18:21:37.064522 [ERROR] nginx: the configuration file /var/proxy/staging/nginx/nginx.conf syntax is ok
nginx: configuration file /var/proxy/staging/nginx/nginx.conf test is successful