我在应用程序ELB后面遇到Nginx配置问题。 我们有: - AWS Application Load Balancer - application-elb.com - 附加路径/ appserver - 具有Nginx和PHP应用程序的ECS容器
请帮我处理Nginx配置,以便将请求转发到application-elb.com/appserver而不是application-elb.com。
目前有配置:
server {
listen 80;
access_log /var/log/nginx/appserver.access.log;
error_log /var/log/nginx/appserver.error.log;
root /appserver/web;
#site root is redirected to the app boot script
location = / {
try_files @site @site;
}
#all other locations try other files first and go to our front controller if none of them exists
location / {
try_files $uri $uri/ @site;
}
#return 404 for all php files as we do have a front controller
location ~ \.php$ {
return 404;
}
location @site {
fastcgi_pass 127.0.0.1:9000;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root/index.php;
fastcgi_param IBE_ENV dev;
}
}
更新
我在不改变Nginx配置的情况下解决了这个问题。解决方案非常简单,我相信它可以更正确地完成。我在PHP代码中找到了路由并添加了适当的路径。在这些变化之后,一切都很好。