Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

888
Vistas
AWS Elastic Beanstalk + Laravel, Nginx Configuration

Recently AWS started distributing the Elastic Beanstalk PHP environment with Amazon Linux 2, which has dropped apache in favor of Nginx, I've been trying to correctly configure my Laravel project to work, I used to just have to add some .htaccess configuration and that was it, on Nginx I can't seem to figure out how to make my app to work, my first issue was the reverse proxy port, which I fixed by setting PORT environment variable to 80, but when I try to access any route from the URL aside from /, it gives me an 404 Not Found error.

so I tried to add a .ebextension/Nginx/nginx.conf to my project containing the following:

user                    nginx;
error_log               /var/log/nginx/error.log warn;
pid                     /var/run/nginx.pid;
worker_processes        auto;
worker_rlimit_nofile    33282;

events {
    worker_connections  1024;
}

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"';

  include       conf.d/*.conf;

  map $http_upgrade $connection_upgrade {
      default     "upgrade";
  }

  server {
      listen 80 default_server;
      root /var/app/current/public;

      location / {
           try_files $uri $uri/ /index.php?$query_string;
      }

      location = /favicon.ico { access_log off; log_not_found off; }
      location = /robots.txt  { access_log off; log_not_found off; }

      error_page 404 /index.php;

      location ~ \.php$ {
        fastcgi_pass unix:/var/run/php-fpm/www.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
        include fastcgi_params;
      }

      location ~ /\.(?!well-known).* {
         deny all;
      }

      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/01_static.conf;
      include conf.d/elasticbeanstalk/healthd.conf;
  }
}

but it didn't work, I tried to check if the configs ware applied on the instance, but /etc/Nginx/Nginx.conf did not change.

How can I configure an Elastic Beanstalk PHP Amazon Linux 2 through .ebextensions to make Nginx work with a stateless Laravel application?

Thank you!

over 4 years ago · Santiago Trujillo
3 Respuestas
Responde la pregunta

0

I manually added a file to /etc/nginx/conf.d/elasticbeanstalk/ and named it laravel.conf. The laravel.conf file contained:

 location / { try_files $uri $uri/ /index.php?$query_string; gzip_static on; }

Complete solution:

https://forums.aws.amazon.com/thread.jspa?threadID=321787&tstart=0

over 4 years ago · Santiago Trujillo Denunciar

0

The correct way would be to add this file inside

 .platform/nginx/conf.d/elasticbeanstalk/laravel.conf

Here is a link to the docs:

https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/platforms-linux-extend.html

over 4 years ago · Santiago Trujillo Denunciar

0

The right way to do it is to create the following folder structure in the root of your laravel project

.platform/nginx/conf.d/elasticbeanstalk/laravel.conf (or any other file name with the ending .conf) and enter the following code:

location / {
try_files $uri $uri/ /index.php?$query_string;
}
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda