我想在 Amazon Linux 实例中使用 Nginx。如果我使用具有 Amazon 授予的公共 IP 的单个实例,则配置有效。然后,当我添加 ALB 并稍后添加目标组时,应用程序失败。与 apache 相同的配置可以正常工作。可能是什么问题?这是我的 /etc/nginx/conf.d/app.conf 配置
# 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;
}
}