File server with automatic HTTPS and Cloudflare DNS management
Project description
file-server-auto-https
A CLI tool for creating file servers with automatic HTTPS using Cloudflare DNS. This tool automatically generates subdomains on your domain and configures Cloudflare's Flexible SSL for secure access.
Features
- Automatic subdomain generation for your domain
- Cloudflare DNS management
- Public and local IP detection
- Flexible SSL through Cloudflare
- Rich CLI interface with detailed feedback
Prerequisites
- Python 3.8 or higher
- A Cloudflare account
- A domain managed by Cloudflare
- Cloudflare API credentials
Installation
- Clone the repository:
git clone https://github.com/yourusername/file-server-auto-https.git
cd file-server-auto-https
- Install dependencies:
pip install -e .
Configuration
Create a .env file in the project root with your Cloudflare credentials:
CLOUDFLARE_EMAIL=your-email@example.com
CLOUDFLARE_API_KEY=your-api-key
CLOUDFLARE_ZONE_ID=your-zone-id # Zone ID for your domain
BASE_DOMAIN=your-domain.com
To find your Zone ID:
- Log into your Cloudflare dashboard
- Select your domain
- The Zone ID is shown in the Overview tab's API section
Usage
The tool provides a CLI interface with various commands:
Create DNS Record
Create a new subdomain pointing to your server:
# Basic usage (auto-detects public IP)
file-server dns create
# Specify custom IP
file-server dns create --ip 1.2.3.4
# Use local IP instead of public
file-server dns create --no-use-public-ip
# Specify custom subdomain
file-server dns create --subdomain myserver
# Custom subdomain length (for random generation)
file-server dns create --length 12
# Disable Cloudflare proxying
file-server dns create --no-proxied
List DNS Records
View existing DNS records:
# List records created by this tool
file-server dns list-records
# List all DNS records in the zone
file-server dns list-records --show-all
Delete DNS Record
Delete a DNS record by its ID:
# Delete a record (get ID from list-records command)
file-server dns delete RECORD_ID
Command Options
Create
--ip: Specify IP address manually--use-public-ip: Use public IP (default: True)--subdomain: Specify custom subdomain--length: Length of random subdomain (default: 8)--proxied: Enable/disable Cloudflare proxying (default: True)
List
--show-all: Show all records, not just those created by this tool
Development
Running Tests
The project uses pytest for testing. To run the tests:
# Install development dependencies
pip install -e ".[dev]"
# Run all tests
pytest
# Run tests with coverage
pytest --cov=file_server_auto_https
# Run specific test file
pytest tests/test_generate_dns_record.py
Test Structure
test_generate_dns_record.py: Tests for DNS record generation- Subdomain generation
- DNS record creation
- Error handling
- Configuration validation
SSL/TLS
This project uses Cloudflare's Flexible SSL:
- HTTPS between visitors and Cloudflare
- HTTP between Cloudflare and your server
- No need to generate/manage SSL certificates
- Enabled automatically when
proxied=True
Troubleshooting
DNS Record Not Appearing
If your DNS record isn't appearing in Cloudflare:
-
Check your credentials:
# List existing records to verify API access file-server dns list-records --show-all
-
Verify the API response: The create command now shows the raw API response for debugging.
-
Common issues:
- Incorrect Zone ID
- API key permissions (needs DNS Write access)
- Rate limiting
- Invalid subdomain format
If you're still having issues, check the error messages in the command output for more details.
License
GPL-3.0
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file file_server_auto_https-0.2.0.tar.gz.
File metadata
- Download URL: file_server_auto_https-0.2.0.tar.gz
- Upload date:
- Size: 24.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cc994ad326aea1631425d53af8afc54e1a814e15a7c13471c178705f6bb3e3cb
|
|
| MD5 |
f33c17f71681e96a3854e967b50d0f18
|
|
| BLAKE2b-256 |
5f07cccc6af5a2ca647029a26c90e1981c7106a56ca6735eac69180b40af7b55
|
File details
Details for the file file_server_auto_https-0.2.0-py3-none-any.whl.
File metadata
- Download URL: file_server_auto_https-0.2.0-py3-none-any.whl
- Upload date:
- Size: 27.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9d327a5747a6a354000bfb01f31d2caf0c73bf2c760adaecd0e6fae467e72fa4
|
|
| MD5 |
d1d73ac4a686864ebcf18d7703550afa
|
|
| BLAKE2b-256 |
5273e56647c73c5f472ab34c443786dd73c126445bf9f3b8863c38f1edd0f7d3
|