- Newest
- Most votes
- Most comments
While AWS Amplify doesn't natively support path-based routing for multiple applications under a single domain, you can achieve this setup using an NGINX proxy in combination with Amazon API Gateway or Amazon CloudFront.
Here's a high-level approach to implement path-based routing for your Amplify apps:
-
Set up an NGINX server as a reverse proxy. This can be done on an EC2 instance or using a container service like ECS or EKS.
-
Configure NGINX to route requests based on the path. Your NGINX configuration would look something like this:
server {
listen 80;
server_name mydomain.com;
location /app1 {
proxy_pass https://app1.amplifyapp.com;
}
location /app2 {
proxy_pass https://app2.amplifyapp.com;
}
location /app3 {
proxy_pass https://app3.amplifyapp.com;
}
}
-
Use Amazon API Gateway or Amazon CloudFront as the entry point for your domain (mydomain.com). This will handle SSL termination and provide additional features like caching and security.
-
Configure API Gateway or CloudFront to forward requests to your NGINX server.
-
Set up your DNS (Route 53 or another DNS provider) to point mydomain.com to the API Gateway or CloudFront distribution.
This approach allows you to maintain the benefits of Amplify for each individual app while providing a unified entry point for your users. It's important to note that this setup introduces additional complexity and potential points of failure, so you'll need to ensure proper monitoring and management of the NGINX server.
Alternatively, if you're open to restructuring your application, you could consider consolidating your microservices into a single Amplify app with different routes. This would allow you to use Amplify's built-in routing capabilities and avoid the need for an external proxy.
Remember to carefully consider factors like scalability, maintenance, and cost when implementing this solution. You may also want to explore other AWS services like Application Load Balancer or AppSync if they better suit your specific use case.
Sources
Path routing pattern - AWS Prescriptive Guidance
answered 2 years ago
Hi,
This article show how to use nginx on AWS for HA purposes but it can be easily adapted to your purpose of path-based routing: https://docs.nginx.com/nginx/deployment-guides/amazon-web-services/high-availability-network-load-balancer/
From the same perspective of routing, but with solutions different from nginx, you should read:
- https://aws.amazon.com/blogs/architecture/serving-content-using-fully-managed-reverse-proxy-architecture/
- https://hitaha.medium.com/path-based-routing-on-aws-cloudfront-host-multiple-amplify-and-s3-apps-under-one-domain-3d47dda9e2c3
- https://medium.com/@nadarajangs31/achieving-path-based-routing-with-amplify-url-and-cloudfront-for-multiple-angular-applications-a31095fced8b
Best,
Didier
Relevant content
asked a year ago
- AWS OFFICIALUpdated 4 years ago

can u explain in details bcz cloudfront not able to access amplify url it show 403 error