jekyll build from Action 4ae1c2cd4aa8f23068f0fa2c7ebd5e75d2bad095
This commit is contained in:
parent
db6e2ef96d
commit
ed22b2e1e9
File diff suppressed because one or more lines are too long
18
domains.yaml
Normal file
18
domains.yaml
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
reserved_domains:
|
||||||
|
- "^(www\\.|api\\.|mail\\.|status\\.)morlana\\.page$"
|
||||||
|
- "^admin\\..*"
|
||||||
|
- "^internal\\..*"
|
||||||
|
|
||||||
|
subdomains:
|
||||||
|
- name: www
|
||||||
|
target: pages.morlana-pages.morlana.morlana.space
|
||||||
|
proxy: false
|
||||||
|
note: "Currently the cloudflare proxy service is not supported by Morlana Git Pages service"
|
||||||
|
# - name: "example"
|
||||||
|
# target: "example.com"
|
||||||
|
# proxy: true
|
||||||
|
# note: "Test Subdomain"
|
||||||
|
# - name: "test"
|
||||||
|
# target: "test.example.com"
|
||||||
|
# proxy: false
|
||||||
|
# note: "Proxy deaktiviert"
|
2
feed.xml
2
feed.xml
@ -1 +1 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="4.3.4">Jekyll</generator><link href="https://morlana.page/feed.xml" rel="self" type="application/atom+xml" /><link href="https://morlana.page/" rel="alternate" type="text/html" /><updated>2025-03-02T23:08:47+00:00</updated><id>https://morlana.page/feed.xml</id><title type="html">Morlana - Pages</title><subtitle>Free Subdomains provided by Morlana</subtitle></feed>
|
<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="4.3.4">Jekyll</generator><link href="https://morlana.page/feed.xml" rel="self" type="application/atom+xml" /><link href="https://morlana.page/" rel="alternate" type="text/html" /><updated>2025-03-03T00:03:15+00:00</updated><id>https://morlana.page/feed.xml</id><title type="html">Morlana - Pages</title><subtitle>Free Subdomains provided by Morlana</subtitle></feed>
|
56
index.md
Normal file
56
index.md
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
---\nlayout: default\ntitle: Documentation\n---\n\n
|
||||||
|
# Morlana Pages Free Subdomain Service
|
||||||
|
|
||||||
|
## Overview
|
||||||
|
This repository provides a free subdomain service for the `morlana.page` domain, similar to `js.org`. Users can request a subdomain by forking this repository, adding their domain entry to `domains.yaml`, and submitting a pull request.
|
||||||
|
|
||||||
|
## How It Works
|
||||||
|
1. Fork this repository.
|
||||||
|
2. Add your subdomain entry to `domains.yaml`, ensuring it is in alphabetical order.
|
||||||
|
3. Submit a pull request.
|
||||||
|
4. Once the PR is approved and merged, an automated workflow updates the DNS records via the Cloudflare API.
|
||||||
|
|
||||||
|
## Subdomain Requirements
|
||||||
|
- Only **CNAME** records are allowed.
|
||||||
|
- The Cloudflare proxy is **enabled by default**, but can be disabled per subdomain.
|
||||||
|
- Reserved domains cannot be registered (e.g., `www.morlana.page`).
|
||||||
|
|
||||||
|
## How to Request a Subdomain
|
||||||
|
### 1. Edit `domains.yaml`
|
||||||
|
Add your subdomain under the `subdomains` section:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
subdomains:
|
||||||
|
- name: "your-subdomain"
|
||||||
|
target: "your-site.example.com"
|
||||||
|
proxy: true # Set to false if you want to disable the Cloudflare proxy
|
||||||
|
note: "Optional description"
|
||||||
|
```
|
||||||
|
|
||||||
|
### 2. Submit a Pull Request
|
||||||
|
- Ensure that your subdomain entry is in **alphabetical order**.
|
||||||
|
- Verify that your CNAME target is correct.
|
||||||
|
- Create a pull request with your changes.
|
||||||
|
|
||||||
|
## Reserved Domains
|
||||||
|
Some subdomains are **reserved** and cannot be registered. The list includes:
|
||||||
|
- `www.morlana.page`
|
||||||
|
- `api.morlana.page`
|
||||||
|
- `mail.morlana.page`
|
||||||
|
- Domains matching specific patterns (e.g., `admin.*`, `internal.*`).
|
||||||
|
|
||||||
|
## Automation
|
||||||
|
Once a pull request is merged, a GitHub Action will:
|
||||||
|
1. Validate the `domains.yaml` file.
|
||||||
|
2. Check for duplicate or reserved domains.
|
||||||
|
3. Update the Cloudflare DNS settings automatically.
|
||||||
|
|
||||||
|
## Setup for Maintainers
|
||||||
|
### Environment Variables
|
||||||
|
To enable Cloudflare DNS updates, set the following secrets in Gitea:
|
||||||
|
- `CLOUDFLARE_API_TOKEN`: API token with DNS write access.
|
||||||
|
- `CLOUDFLARE_ZONE_ID`: Cloudflare Zone ID for `morlana.page`.
|
||||||
|
|
||||||
|
## License
|
||||||
|
This project is open-source and licensed under the BSD-3-Clause.
|
||||||
|
|
71
update_cloudflare_dns.py
Normal file
71
update_cloudflare_dns.py
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
import yaml
|
||||||
|
import requests
|
||||||
|
import re
|
||||||
|
import os
|
||||||
|
|
||||||
|
# Cloudflare API Konfiguration
|
||||||
|
CLOUDFLARE_API_TOKEN = os.getenv("CLOUDFLARE_API_TOKEN")
|
||||||
|
CLOUDFLARE_ZONE_ID = os.getenv("CLOUDFLARE_ZONE_ID")
|
||||||
|
CLOUDFLARE_API_URL = f"https://api.cloudflare.com/client/v4/zones/{CLOUDFLARE_ZONE_ID}/dns_records"
|
||||||
|
|
||||||
|
HEADERS = {
|
||||||
|
"Authorization": f"Bearer {CLOUDFLARE_API_TOKEN}",
|
||||||
|
"Content-Type": "application/json"
|
||||||
|
}
|
||||||
|
|
||||||
|
def load_domains(file_path="domains.yaml"):
|
||||||
|
with open(file_path, "r") as file:
|
||||||
|
return yaml.safe_load(file)
|
||||||
|
|
||||||
|
def is_reserved(domain, reserved_patterns):
|
||||||
|
return any(re.match(pattern, domain) for pattern in reserved_patterns)
|
||||||
|
|
||||||
|
def get_existing_records():
|
||||||
|
response = requests.get(CLOUDFLARE_API_URL, headers=HEADERS)
|
||||||
|
if response.status_code == 200:
|
||||||
|
return {rec["name"]: rec for rec in response.json().get("result", [])}
|
||||||
|
return {}
|
||||||
|
|
||||||
|
def update_cloudflare():
|
||||||
|
data = load_domains()
|
||||||
|
reserved_patterns = data.get("reserved_domains", [])
|
||||||
|
subdomains = {f"{sub['name']}.morlana.page": sub for sub in data.get("subdomains", [])}
|
||||||
|
|
||||||
|
existing_records = get_existing_records()
|
||||||
|
|
||||||
|
# Entferne Einträge, die nicht mehr in domains.yaml stehen
|
||||||
|
for existing_domain in existing_records:
|
||||||
|
if existing_domain.endswith(".morlana.page") and existing_domain not in subdomains:
|
||||||
|
record_id = existing_records[existing_domain]["id"]
|
||||||
|
response = requests.delete(f"{CLOUDFLARE_API_URL}/{record_id}", headers=HEADERS)
|
||||||
|
if response.status_code == 200:
|
||||||
|
print(f"Successfully removed {existing_domain}")
|
||||||
|
else:
|
||||||
|
print(f"Failed to remove {existing_domain}: {response.text}")
|
||||||
|
|
||||||
|
# Neue Einträge hinzufügen oder bestehende aktualisieren
|
||||||
|
for full_domain, subdomain in subdomains.items():
|
||||||
|
if is_reserved(full_domain, reserved_patterns):
|
||||||
|
print(f"Skipping reserved domain: {full_domain}")
|
||||||
|
continue
|
||||||
|
|
||||||
|
record_data = {
|
||||||
|
"type": "CNAME",
|
||||||
|
"name": full_domain,
|
||||||
|
"content": subdomain["target"],
|
||||||
|
"proxied": subdomain.get("proxy", True)
|
||||||
|
}
|
||||||
|
|
||||||
|
if full_domain in existing_records:
|
||||||
|
record_id = existing_records[full_domain]["id"]
|
||||||
|
response = requests.put(f"{CLOUDFLARE_API_URL}/{record_id}", json=record_data, headers=HEADERS)
|
||||||
|
else:
|
||||||
|
response = requests.post(CLOUDFLARE_API_URL, json=record_data, headers=HEADERS)
|
||||||
|
|
||||||
|
if response.status_code in [200, 201]:
|
||||||
|
print(f"Successfully updated {full_domain}")
|
||||||
|
else:
|
||||||
|
print(f"Failed to update {full_domain}: {response.text}")
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
update_cloudflare()
|
Reference in New Issue
Block a user