I'm looking for a developer-friendly local proxy solution that allows us to avoid remembering or specifying port numbers for our applications. We have around ten apps that each need to run on different ports, and it can get frustrating when developers encounter CORS errors because they're accidentally using the wrong port. Ideally, I want a way to configure everything to run on port 443, using hostnames like payment-local.xxx.dev (since we own a .dev domain). It would also be great to have this configured in a file that we can distribute to dev machines so the apps automatically redirect to the correct ports. Currently, it's manageable, but it would be much more convenient to handle everything without specifying ports.
1 Answer
You can set up an instance of Nginx to run on ports 443 or 80 and proxy your requests to the respective upstream services. Here’s a simple example of how to do it:
```nginx
location /my/app/1 {
proxy_pass http://localhost:4200;
}
location /my/api/2 {
proxy_pass http://localhost:3000;
}
```
This way, you can access everything on port 443 without worrying about specifying the individual ports for each app.

Honestly, moving towards containerization could really streamline things for you. You can run all your apps in Docker containers managed by something like Docker Compose, and use Nginx as your app router, similar to the example above.