Elastic Beanstalk Custom Nginx conf

Solution 1:

  1. For test purposes you can simply create files inside the /etc/nginx/sites-enabled folder

  2. For multiple domains you can use

    server_name *.domain1.com custom.domain2.com;

  3. Lastly, we need to process all PHP files via the FastCGI(on Ubuntu you can install it apt-get install php7.0-fpm) interface to PHP-FPM.

    server {
    listen       80;
    
    server_name  mydomain.com; 
    
    access_log  /var/log/nginx/access.log  combined; 
    location / { 
        root   /var/www/html; 
        try_files $uri $uri/ /index.php?$args;     
    } 
    location ~ \.php$ { 
        fastcgi_pass unix:/var/run/php7.0-fpm.sock; 
        fastcgi_index index.php; 
        fastcgi_param SCRIPT_FILENAME 
         $document_root$fastcgi_script_name; 
        include fastcgi_params; 
    } }