https://github.com/denisetiya/nginx-gateway
A reusable and production-ready API Gateway built on Nginx with: Automatic SSL (Letβs Encrypt), Rate limiting, Easy service registration scripts, Full Docker Compose setup
https://github.com/denisetiya/nginx-gateway
api-gateway config docker docker-compose nginx nginx-api-gateway server-configuration
Last synced: about 2 months ago
JSON representation
A reusable and production-ready API Gateway built on Nginx with: Automatic SSL (Letβs Encrypt), Rate limiting, Easy service registration scripts, Full Docker Compose setup
- Host: GitHub
- URL: https://github.com/denisetiya/nginx-gateway
- Owner: denisetiya
- License: mit
- Created: 2025-09-15T02:59:37.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2025-09-15T03:16:12.000Z (9 months ago)
- Last Synced: 2025-11-10T16:10:23.532Z (7 months ago)
- Topics: api-gateway, config, docker, docker-compose, nginx, nginx-api-gateway, server-configuration
- Language: HTML
- Homepage:
- Size: 13.7 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# π Nginx API Gateway with Rate Limiting & Auto SSL
[](https://nginx.org/)
[](https://docs.docker.com/compose/)
[](./LICENSE)
[](https://letsencrypt.org/)
[](#rate-limiting)
A **reusable** and **production-ready** API Gateway built on **Nginx** with:
- β
Automatic SSL (**Letβs Encrypt**)
- β
Rate limiting per IP
- β
Easy service registration scripts
- β
Full **Docker Compose** setup
---
## β©οΈ Architecture
```mermaid
graph TD
A[Client] --> B(Nginx API Gateway)
B --> C{Rate Limiting}
C --> D[Service 1]
C --> E[Service 2]
C --> F[Service N]
B --> G[(SSL Termination)]
G --> H[Let's Encrypt]
subgraph "API Gateway"
B
C
G
end
subgraph "Services"
D
E
F
end
subgraph "Security"
H
end
```
## β¨ Features
* π **Security by default** β SSL, security headers, CORS
* β‘ **Rate limiting** β 10 r/s per IP (burst 20)
* π³ **Dockerized** β Ready to deploy with `docker-compose`
* π οΈ **Easy service config** β Add new APIs with a single script
---
## π Prerequisites
* [Docker](https://docs.docker.com/get-docker/) & [Docker Compose](https://docs.docker.com/compose/)
* A domain name pointing to your server
---
## βοΈ Setup Instructions
1. **Configure Docker Compose**
Edit [`docker-compose.yml`](./docker-compose.yml):
* Replace `your-email@example.com`
* Replace `your-domain.com`
2. **Start the gateway**
```bash
docker-compose up -d
```
3. **Add new services**
Linux/Mac:
```bash
./add-service.sh SERVICE_NAME SERVICE_PORT SERVICE_PREFIX DOMAIN
```
Windows:
```cmd
add-service.bat SERVICE_NAME SERVICE_PORT SERVICE_PREFIX DOMAIN
```
Example:
```bash
./add-service.sh user-service 3000 /api/users example.com
```
4. **Restart Nginx**
```bash
docker-compose restart nginx
```
---
## π§ Configuration
### Rate Limiting
```nginx
limit_req_zone $binary_remote_addr zone=api:10m rate=10r/s;
```
* Default: `10r/s` per IP
* Burst: `20 requests`
* Zone size: `10MB (~160k IPs)`
### SSL
```nginx
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers HIGH:!aNULL:!MD5;
```
* Certificates managed by **Certbot**
* Stored in `/ssl`
* Auto renewal enabled
---
## π Troubleshooting
* **Check SSL logs**
```bash
docker-compose logs certbot
```
* **Test Nginx config**
```bash
docker-compose exec nginx nginx -t
```
* **Check rate limit logs**
```bash
docker-compose logs nginx
```
---
## π Directory Structure
```
nginx-gateway/
βββ docker-compose.yml # Docker Compose config
βββ nginx.conf # Main Nginx config
βββ conf.d/ # Service configs
β βββ service-template.conf
βββ ssl/ # SSL certificates
βββ www/ # Certbot webroot
β βββ rate-limit.html
βββ logs/ # Nginx logs
βββ add-service.sh # Add service (Linux/Mac)
βββ add-service.bat # Add service (Windows)
```
---
## π Example Usage
See [example-usage.md](./example-usage.md) for real service integration examples.
---
## π License
This project is open source and available under the MIT License. See the [LICENSE](LICENSE) file for more information.
---