A modern, fast URL shortener built with Go Fiber framework and Redis database, featuring a beautiful web interface and Docker deployment.
- 🔗 URL Shortening: Convert long URLs into short, shareable links
- ⏱️ Rate Limiting: 10 requests per IP per 30 minutes
- ⏰ Auto Expiry: Links expire after 24 hours
- 🎨 Beautiful UI: Modern, responsive web interface
- 🔧 Custom Short Codes: Optional custom URL codes
- 📋 Copy to Clipboard: One-click copying
- 🐳 Docker Ready: Containerized for easy deployment
- ☁️ Cloud Deployable: Ready for Render, AWS, GCP, etc.
- Backend: Go with Fiber framework
- Database: Redis
- Frontend: HTML, CSS, JavaScript
- Containerization: Docker & Docker Compose
- Deployment: Render (or any Docker-compatible platform)
-
Clone the repository:
git clone <your-repo-url> cd shorten-url-fiber-redis
-
Start with Docker Compose:
docker-compose up
-
Access the application:
- Open
http://localhost:3000in your browser - Start shortening URLs!
- Open
Deploy to Render in minutes:
-
Fork this repository to your GitHub account
-
Deploy to Render:
- Go to render.com
- Create new Blueprint
- Connect your repository
- Render will auto-detect
render.yaml
-
Access your live app:
- Your URL:
https://your-service-name.onrender.com
- Your URL:
📖 Detailed deployment guide: DEPLOY.md
- Enter URL: Paste any long URL
- Custom Code (optional): Add your custom short code
- Shorten: Click the button to generate short URL
- Copy & Share: Use the copy button to share your link
- POST
/api/v1- Shorten a URL - GET
/:shortCode- Redirect to original URL
curl -X POST http://localhost:3000/api/v1 \
-H "Content-Type: application/json" \
-d '{
"url": "https://www.example.com/very/long/url",
"short": "custom123",
"expiry": 24
}'Response:
{
"url": "https://www.example.com/very/long/url",
"short": "http://localhost:3000/custom123",
"expiry": 24,
"rate_limit_remaining": 9,
"rate_limit_reset": 30
}shorten-url-fiber-redis/
├── api/ # Go application
│ ├── database/ # Redis connection
│ ├── helpers/ # Utility functions
│ ├── routes/ # API routes
│ ├── static/ # Frontend files
│ ├── main.go # Application entry point
│ ├── Dockerfile # Container for local dev
│ └── .env # Environment variables
├── db/ # Redis configuration
├── docker-compose.yaml # Local development setup
├── Dockerfile # Production container
├── render.yaml # Render deployment config
└── DEPLOY.md # Deployment guide
| Variable | Description | Default |
|---|---|---|
PORT |
Server port (set by deployment platform) | 3000 |
APP_PORT |
Local development port | :3000 |
DOMAIN |
Base domain for shortened URLs | http://localhost:3000 |
API_QUOTA |
Rate limit per 30 minutes | 10 |
DB_ADDR |
Redis connection string | db:6379 |
DB_PASS |
Redis password | (empty) |
Edit api/.env:
APP_PORT=:3000
DOMAIN=http://localhost:3000
API_QUOTA=10
DB_ADDR=db:6379
DB_PASS=Set environment variables in your deployment platform dashboard.
- ✅ Rate limiting per IP address
- ✅ URL validation and sanitization
- ✅ HTTPS enforcement in production
- ✅ Non-root container execution
- ✅ Input validation and error handling
- Responsive Design: Works on all devices
- Real-time Rate Limiting: Shows remaining requests
- Countdown Timer: Shows when rate limit resets
- Error Handling: Clear error and success messages
- Copy to Clipboard: Modern clipboard API with fallback
- Form Validation: Client-side URL validation
docker-compose updocker build -t url-shortener .
docker run -p 3000:3000 url-shortener- Request Logs: Fiber middleware logging
- Rate Limiting: Redis-based tracking
- Error Handling: Comprehensive error responses
- Health Checks: Built-in endpoint monitoring
This application is ready to deploy on:
- Render (recommended) - Deploy Guide
- Heroku - Set environment variables and deploy
- Railway - Connect GitHub and deploy
- AWS/GCP - Use the production Dockerfile
- DigitalOcean App Platform - Deploy from GitHub
- Fork the repository
- Create a feature branch
- Make your changes
- Test locally with
docker-compose up - Submit a pull request
This project is open source and available under the MIT License.
- Documentation: Check DEPLOY.md for deployment help
- Issues: Create a GitHub issue for bugs or feature requests
- Questions: Use GitHub Discussions for questions
Made with ❤️ using Go Fiber and Redis
🔗 Live Demo: Deploy your own | ⭐ Star this repo if you found it helpful!