I am trying to run two React applications and an API server in an EC2 instance and reverse-proxy using NGINX using docker-compose.
When I navigate to example.com
, the client app is loaded as expected. However, when I navigate to example.com/admin
the admin app is not loaded. The tab name and icon are the ones of the admin app, however the page is completely blank. I am sure it is not the admin app the problem because if I change the proxy_pass
directive in the default.conf
file for the /
location it is loaded as expected. What am I missing then?
Hereafter is the default.conf
for NGINX (HTTPS is not implemented yet):
server {
server_name www.example.com;
rewrite ^(.*) http://example.com$1 permanent;
}
server {
listen 80;
listen [::]:80;
root /var/www/html;
index index.html index.htm index.nginx-debian.html;
server_name example.com www.example.com;
location / {
proxy_pass http://client:3000;
}
location /admin {
proxy_pass http://admin:3001;
}
location /api {
proxy_pass http://server:5000;
}
location ~ /.well-known/acme-challenge {
allow all;
try_files $uri =404;
break;
}
}
Hereafter is the docker-compose.yml
file:
version: '3.7'
services:
client:
image: app_client
container_name: client
restart: unless-stopped
hostname: client
ports:
- '3000:3000'
networks:
- network
admin:
image: app_admin
container_name: admin
restart: unless-stopped
hostname: admin
ports:
- '3001:3001'
networks:
- network
mongodb:
image: app_mongodb
container_name: mongodb
restart: unless-stopped
hostname: mongodb
volumes:
- mongo-data:/data/db
ports:
- '27017:27017'
networks:
- network
server:
image: app_server
container_name: server
restart: unless-stopped
hostname: server
ports:
- '5000:5000'
depends_on:
- mongodb
networks:
- network
proxy:
image: app_proxy
container_name: proxy
hostname: proxy
restart: unless-stopped
ports:
- '80:80'
- '443:443'
volumes:
- web-root:/var/www/html
- certbot-etc:/etc/letsencrypt
- certbot-var:/var/lib/letsencrypt
depends_on:
- client
- server
networks:
- network
certbot:
...
networks:
network:
driver: bridge
volumes:
mongo-data:
driver: local
certbot-etc:
certbot-var:
web-root:
driver: local