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 dockerrun.aws.json 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 https://mydomain.com/strapi
When I go to mydomain.com/strapi i get an endless pending redirect to https://mydomain.com/strapi:8080. 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_pass http://127.0.0.1:1337;
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;
}
}
}