Running strapi in a container in ECS. Cannot access due to redirects

System Information
  • Strapi Version: 4
  • Operating System: Mac
  • Database: Postgres
  • Node Version: 16
  • NPM Version:
  • Yarn Version:

The title needs some work for sure. So here’s what I have:

  • ElasticBeanstalk Environment (ECS running on 64bit Amazon Linux 2/3.2.8)
  • 3 containers. 1 of which is Strapi with Nginx
  • In my file, I’ve exposed ports to allow access to these containers
  • In my ALB I’ve configured rules that allow paths (ie./strapi) to forward to those ports
  • According to the docs, I needed to include an nginx.conf to rewrite the /strapi path to /
  • I’ve also configured my server.js file to set url to

When I go to i get an endless pending redirect to Yes, thats right, the port is included as well. 8080 is the port I have exposed the nginx/strapi container.

Here’s my nginx.conf:

worker_processes 1;

events {
    worker_connections 1024;

http {
server {
    listen 8080;
    server_name localhost;

    location / {
      return 200;

    location /strapi/ {
        rewrite ^/strapi/?(.*)$ /$1 break;
        proxy_http_version 1.1;
        proxy_set_header X-Forwarded-Host $host;
        proxy_set_header X-Forwarded-Server $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header Host $http_host;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "Upgrade";
        proxy_pass_request_headers on;

For those curious, I replaced the rewrite stuff with a ‘return 200;’ and it works as expected. I’m not sure where I’m going wrong here. Please help.