ImgTunnel is a secure image CDN system that allows users to upload images and protects access to them. Only authorized domains can access uploaded content.
- Secure image upload system via
upload.php
- Protected image serving with domain verification (
serve.php
) - Organized folder structure with separation between public and protected files
- Environment configuration using
.env
for sensitive data - Simple UI via
test.html
for image upload testing
IMAGE\_CDN\_ALL\_IMAGES/
├── uploads/ # Public images (if needed)
├── uploads\_protected/ # Protected, non-public images
├── .env # Environment variables (DB credentials)
├── db.php # DB connection using env
├── index.php # Entry or redirect page (optional)
├── serve.php # Serves images with domain checks
├── test.html # Basic frontend for image upload
├── upload.php # Handles image upload securely
- Clone the repository:
git clone https://github.com/yourusername/imgtunnel.git
cd imgtunnel
- Setup
.env
file:
Create a .env
file at the root:
DB_HOST=localhost
DB_USER=root
DB_PASSWORD=
DB_NAME=image_cdn
- Create MySQL database:
Create a database called image_cdn
and a table allowed_domains
:
CREATE DATABASE image_cdn;
USE image_cdn;
CREATE TABLE allowed_domains (
id INT AUTO_INCREMENT PRIMARY KEY,
domain VARCHAR(255) NOT NULL
);
INSERT INTO allowed_domains (domain) VALUES ('localhost'),('yourdomain.com');
- Place the project in your XAMPP
htdocs
folder:
C:\xampp\htdocs\IMG_CDN_ALL_IMAGES\
- Start XAMPP (Apache & MySQL) and visit:
http://localhost/IMAGE_CDN_ALL_IMAGES/test.html
Only requests from allowed domains (defined in DB) can access protected images through serve.php
.
Upload: Send a POST request to:
http://localhost/IMAGE_CDN_ALL_IMAGES/upload.php
Access:
Use serve.php
with query param:
http://localhost/IMAGE_CDN_ALL_IMAGES/serve.php?file=your_image_name.png
If the domain is not allowed, it will return "Access denied".
This project is licensed under the MIT License.
Made with 🔐 by ImgTunnel