Add default backend page for unmatched domains
All checks were successful
HAProxy Manager Build and Push / Build-and-Push (push) Successful in 37s
All checks were successful
HAProxy Manager Build and Push / Build-and-Push (push) Successful in 37s
- Add default backend template (hap_default_backend.tpl) - Add customizable default page HTML template (default_page.html) - Modify generate_config() to include default backend for unmatched domains - Add environment variables for customizing default page content: - HAPROXY_DEFAULT_PAGE_TITLE - HAPROXY_DEFAULT_MAIN_MESSAGE - HAPROXY_DEFAULT_SECONDARY_MESSAGE - Update README with documentation and examples - Ensure backward compatibility with existing configurations - Remove email contact link as requested
This commit is contained in:
91
templates/default_page.html
Normal file
91
templates/default_page.html
Normal file
@@ -0,0 +1,91 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>{{ page_title }}</title>
|
||||
<style>
|
||||
body {
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
|
||||
text-align: center;
|
||||
padding: 50px 20px;
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
margin: 0;
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
.container {
|
||||
background: white;
|
||||
padding: 40px;
|
||||
border-radius: 12px;
|
||||
box-shadow: 0 10px 30px rgba(0,0,0,0.2);
|
||||
max-width: 600px;
|
||||
width: 100%;
|
||||
}
|
||||
.icon {
|
||||
font-size: 64px;
|
||||
margin-bottom: 20px;
|
||||
display: block;
|
||||
}
|
||||
h1 {
|
||||
color: #e74c3c;
|
||||
margin-bottom: 20px;
|
||||
font-size: 2.2em;
|
||||
font-weight: 600;
|
||||
}
|
||||
p {
|
||||
color: #555;
|
||||
line-height: 1.7;
|
||||
margin-bottom: 15px;
|
||||
font-size: 1.1em;
|
||||
}
|
||||
.contact {
|
||||
background: linear-gradient(135deg, #3498db, #2980b9);
|
||||
color: white;
|
||||
padding: 12px 24px;
|
||||
border-radius: 6px;
|
||||
text-decoration: none;
|
||||
display: inline-block;
|
||||
margin-top: 25px;
|
||||
font-weight: 500;
|
||||
transition: transform 0.2s ease, box-shadow 0.2s ease;
|
||||
}
|
||||
.contact:hover {
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 5px 15px rgba(52, 152, 219, 0.4);
|
||||
}
|
||||
.domain-info {
|
||||
background: #f8f9fa;
|
||||
border: 1px solid #e9ecef;
|
||||
border-radius: 6px;
|
||||
padding: 15px;
|
||||
margin: 20px 0;
|
||||
font-family: 'Courier New', monospace;
|
||||
color: #495057;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<span class="icon">⚠️</span>
|
||||
<h1>{{ page_title }}</h1>
|
||||
<p>{{ main_message }}</p>
|
||||
<p>{{ secondary_message }}</p>
|
||||
|
||||
<div class="domain-info">
|
||||
<strong>Domain:</strong> <span id="domain"></span><br>
|
||||
<strong>Time:</strong> <span id="timestamp"></span>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<script>
|
||||
// Display the current domain and timestamp
|
||||
document.getElementById('domain').textContent = window.location.hostname;
|
||||
document.getElementById('timestamp').textContent = new Date().toLocaleString();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
12
templates/hap_default_backend.tpl
Normal file
12
templates/hap_default_backend.tpl
Normal file
@@ -0,0 +1,12 @@
|
||||
# Default backend for unmatched domains
|
||||
backend default-backend
|
||||
mode http
|
||||
option http-server-close
|
||||
http-request set-header X-Forwarded-Proto https if { ssl_fc }
|
||||
http-request set-header X-Forwarded-Port %[dst_port]
|
||||
http-request set-header X-Forwarded-For %[src]
|
||||
http-request set-header X-Real-IP %[src]
|
||||
|
||||
# Serve the default page HTML response
|
||||
http-response set-header Content-Type text/html
|
||||
http-response set-body "{{ default_page_content }}"
|
Reference in New Issue
Block a user