How to configure NGINX conf location to work with AWS ALB? I have a docker-compose that simulates a staging environment that is deployed to AWS ECS, that works fine, status 200 OK:
/review-staging 200 OK
/review-staging/wp-admin 200 OK
/review-staging/graphql 200 OK
Although this works great through Docker-compose setup, the same does not happen once I run the requests against the AWS version, for one particular path tested so far /review-staging/wp-admin
. As follows:
/review-staging 200 OK
/review-staging/wp-admin 302 fail (Browser throws ERR_TOO_MANY_REDIRECTS)
/review-staging/graphql 200 OK
The CloudWatch logs shows serveral of these:
17/Oct/2019:01:54:07 +0000 "GET /review-ci/wp-admin/index.php" 302
The NGINX conf file I have is:
server {
listen 80;
server_name foobar;
root /var/www/html;
index index.php index.html index.htm;
charset UTF-8;
autoindex off;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
client_max_body_size 200m;
# Do not log access to these to keep the logs cleaner
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /apple-touch-icon.png {
log_not_found off;
access_log off;
}
location = /apple-touch-icon-precomposed.png {
log_not_found off;
access_log off;
}
location / {
try_files $uri $uri/ =404;
}
location ~ /elbhealth {
add_header Content-Type text/html;
return 200 'OK';
}
location /review-staging {
try_files $uri $uri/ /review-staging/index.php?$args;
}
# Fix for Firefox issue with cross site font icons
location ~* \.(eot|otf|ttf|woff)$ {
add_header Access-Control-Allow-Origin *;
}
# Deny access to any files with a .php extension in the uploads directory
location ~* /(?:uploads|files)/.*\.php$ {
deny all;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass php-fpm:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
location ~ \.(js|css|png|jpg|woff|gif|ttf|ico|svg)$ {
try_files $uri =404;
}
}
My expectation is to have it working as it works in docker-compose setup.