A lightweight Nginx proxy server that handles route-based forwarding to multiple backend applications. This project demonstrates how to set up a reverse proxy using Nginx to route traffic to different backend services based on URL paths.
.
├── app1/ # Backend application 1 (runs on port 3000)
├── app2/ # Backend application 2 (runs on port 4000)
├── nginx/
│ └── nginx.conf # Nginx configuration file
└── Dockerfile # Docker configuration for the proxy
- Route-based request forwarding
- Multiple backend service support
- Clean URL rewriting
- Docker containerization support
The proxy is configured to forward requests based on the following rules:
- Requests to
/app1/*are forwarded tohttp://localhost:3000 - Requests to
/app2/*are forwarded tohttp://localhost:4000
- Docker
- Nginx (if running locally)
-
Build the Docker image:
docker build . -t nginx-proxy -
Run the container:
docker run -p 80:80 nginx-proxy
- Ensure Nginx is installed on your system
- Copy the
nginx.confto your Nginx configuration directory - Start Nginx:
nginx -c /path/to/nginx.conf
The main configuration is in nginx/nginx.conf. The configuration includes:
- Upstream server definitions for each backend
- Route-based location blocks
- URL rewriting rules
- Access app1:
http://localhost/app1/ - Access app2:
http://localhost/app2/
Feel free to submit issues and enhancement requests.