wip
This commit is contained in:
parent
fd5840df94
commit
9e295a6f18
2 changed files with 73 additions and 9 deletions
21
app.py
21
app.py
|
@ -20,6 +20,9 @@ DEBUG_MODE = os.getenv('DEBUG_MODE', 'false').lower() == 'true'
|
|||
CADDYFILE_PATH = "/app/Caddyfile" # Fixed internal path
|
||||
NGINX_CONFIG_PATH = os.getenv('NGINX_CONFIG_PATH', '/app/nginx/conf.d') # Path to nginx config directory
|
||||
|
||||
# Add SERVER_NAME environment variable near the top with other configs
|
||||
SERVER_NAME = os.getenv('SERVER_NAME', 'Local Server') # Get server name from env variable
|
||||
|
||||
# Setup logging
|
||||
logging.basicConfig(
|
||||
level=logging.DEBUG if DEBUG_MODE else logging.INFO,
|
||||
|
@ -181,7 +184,9 @@ def index():
|
|||
caddy_count=stats['caddy_servers'],
|
||||
nginx_count=stats['nginx_servers'],
|
||||
domain_count=stats['total_domains'],
|
||||
last_update=stats['last_update'])
|
||||
last_update=stats['last_update'],
|
||||
caddy_proxies=caddy_proxies, # Pass all proxies data
|
||||
nginx_proxies=nginx_proxies) # Pass all proxies data
|
||||
|
||||
@app.route('/caddy')
|
||||
def caddy_dashboard():
|
||||
|
@ -207,7 +212,7 @@ def update_proxies():
|
|||
if not data or not isinstance(data, dict):
|
||||
return jsonify({"status": "error", "message": "Invalid data format"}), 400
|
||||
|
||||
server_name = data.get("server", "Local Server") # Default to 'Local Server' if not provided
|
||||
server_name = data.get("server", SERVER_NAME) # Default to SERVER_NAME if not provided
|
||||
entries = data.get("entries", {})
|
||||
server_type = data.get("type", "caddy").lower() # Default to caddy if not specified
|
||||
|
||||
|
@ -257,15 +262,15 @@ def delete_server():
|
|||
if USE_LOCAL_CADDYFILE:
|
||||
entries = parse_local_caddyfile()
|
||||
if entries:
|
||||
caddy_proxies["Local Server"] = entries
|
||||
timestamps["Local Server"] = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
||||
caddy_proxies[SERVER_NAME] = entries
|
||||
timestamps[SERVER_NAME] = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
||||
logger.info(f"Loaded {len(entries)} entries from local Caddyfile")
|
||||
|
||||
if USE_LOCAL_NGINX:
|
||||
entries = parse_nginx_configs()
|
||||
if entries:
|
||||
nginx_proxies["Local Nginx"] = entries
|
||||
timestamps["Local Nginx"] = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
||||
nginx_proxies[f"{SERVER_NAME} Nginx"] = entries
|
||||
timestamps[f"{SERVER_NAME} Nginx"] = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
||||
logger.info(f"Loaded {len(entries)} entries from local Nginx configs")
|
||||
|
||||
def signal_handler(sig, frame):
|
||||
|
@ -281,8 +286,8 @@ if __name__ == '__main__':
|
|||
# Load it initially
|
||||
local_data = parse_local_caddyfile()
|
||||
if local_data:
|
||||
caddy_proxies["Local Server"] = local_data
|
||||
timestamps["Local Server"] = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
||||
caddy_proxies[SERVER_NAME] = local_data
|
||||
timestamps[SERVER_NAME] = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
||||
|
||||
if not API_KEY:
|
||||
logger.warning("API_KEY not set - running without authentication!")
|
||||
|
|
|
@ -104,7 +104,7 @@
|
|||
</div>
|
||||
|
||||
<!-- Server Selection Cards -->
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-6 mb-6">
|
||||
<a href="/caddy" class="card bg-zinc-900 border border-zinc-800 rounded-lg p-6 hover:border-blue-500/50">
|
||||
<div class="flex items-center mb-4">
|
||||
<div class="w-14 h-14 flex items-center justify-center bg-blue-500/10 text-blue-400 rounded-lg mr-5">
|
||||
|
@ -137,6 +137,65 @@
|
|||
</div>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<!-- Recent Domains List -->
|
||||
<div class="card bg-zinc-900 border border-zinc-800 rounded-lg overflow-hidden mb-6">
|
||||
<div class="px-6 py-4 border-b border-zinc-800">
|
||||
<h3 class="text-lg font-medium text-white">Active Domains</h3>
|
||||
<p class="text-xs text-gray-500 mt-1">All configured domains across servers</p>
|
||||
</div>
|
||||
|
||||
<div class="divide-y divide-zinc-800">
|
||||
{% set domain_list = [] %}
|
||||
{% for server_type, servers in [('caddy', caddy_proxies), ('nginx', nginx_proxies)] %}
|
||||
{% for server, domains in servers.items() %}
|
||||
{% for domain, target in domains.items() %}
|
||||
{% do domain_list.append((domain, target, server, server_type)) %}
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
|
||||
{% for domain, target, server, server_type in domain_list[:20] %}
|
||||
<div class="px-6 py-3 flex items-center justify-between hover:bg-zinc-800/30">
|
||||
<div class="flex items-center">
|
||||
<div
|
||||
class="w-8 h-8 flex-shrink-0 flex items-center justify-center rounded-full
|
||||
{% if server_type == 'caddy' %}bg-blue-500/10 text-blue-400{% else %}bg-green-500/10 text-green-400{% endif %} mr-3">
|
||||
<i class="fas fa-globe text-xs"></i>
|
||||
</div>
|
||||
<div>
|
||||
<a href="https://{{ domain }}" target="_blank"
|
||||
class="text-sm font-medium text-white hover:text-blue-400 transition-colors">
|
||||
{{ domain }}
|
||||
</a>
|
||||
<p class="text-xs text-gray-500">{{ server }}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex items-center">
|
||||
<span class="text-xs text-gray-500 font-mono mr-4">{{ target }}</span>
|
||||
<a href="/{% if server_type == 'caddy' %}caddy{% else %}nginx{% endif %}"
|
||||
class="text-xs px-2 py-1 rounded bg-zinc-800 hover:bg-zinc-700 transition-colors">
|
||||
{{ server_type }}
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
||||
{% if domain_list|length == 0 %}
|
||||
<div class="px-6 py-4 text-gray-500 text-center">
|
||||
<p>No domains configured yet</p>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
{% if domain_list|length > 20 %}
|
||||
<div class="px-6 py-3 border-t border-zinc-800 text-center">
|
||||
<a href="/caddy" class="text-sm text-gray-500 hover:text-white transition-colors">
|
||||
View all {{ domain_list|length }} domains <i class="fas fa-arrow-right ml-1"></i>
|
||||
</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<footer class="py-4 mt-12 border-t border-zinc-900">
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue