TransWikia.com

(AWS) ALB with ec2 instances Amazon Linux and Nginx

Server Fault Asked by user_af on November 18, 2021

I want to use Nginx in Amazon Linux intances. If I use a single instance with a public IP granted by Amazon, the configuration works. Then when I add an ALB and later add the target group the app fails. The same configuration with apache works correctly. What could be the problem?
this is my /etc/nginx/conf.d/app.conf configuration

# PHP Upstream Handler
upstream php-handler {
    server unix:/run/php-fpm/php-fpm.sock;
}
 
server {
    listen 80;
    server_name public-alb.com;
    location / {
        root    /var/www/app;
        index index.php index.html index.htm;
        try_files $uri $uri/ /index.php?$query_string;
    }

    location ~ ^(.+.php)(.*)$ {
        root /var/www/app;
        fastcgi_split_path_info  ^(.+.php)(.*)$;
        fastcgi_index            index.php;
        fastcgi_pass             unix:/run/php-fpm/php-fpm.sock;
        include /etc/nginx/mime.types;
        include                  fastcgi_params;
        fastcgi_param   PATH_INFO       $fastcgi_path_info;
        fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }
}

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP