Skip to content

Instantly share code, notes, and snippets.

@QNimbus
Last active January 28, 2025 10:00
Show Gist options
  • Save QNimbus/3937206d21dc4357096a68e1c61e23af to your computer and use it in GitHub Desktop.
Save QNimbus/3937206d21dc4357096a68e1c61e23af to your computer and use it in GitHub Desktop.
Caddy welcome page
caddy.apps.vwn.io {
root * /srv
file_server
encode gzip zstd
log {
output stdout
format console
}
tls {
dns porkbun {
api_key {env.PORKBUN_API_KEY}
api_secret_key {env.PORKBUN_API_SECRET_KEY}
}
}
}
# Separate block to bind to IPv4 and port 9000 for WebSocket reverse proxy
:9000 {
reverse_proxy http://ocpp-proxy:8080 {
header_up Host {host}
header_up X-Real-IP {remote}
header_up X-Forwarded-For {remote}
header_up X-Forwarded-Proto {scheme}
}
log {
output stdout
format console
}
}
#!/bin/sh
# Copy default Caddyfile if it does not exist
if [ ! -f /etc/caddy/Caddyfile ]; then
echo "Caddyfile not found. Copying default configuration..."
cp /defaults/etc/caddy/Caddyfile /etc/caddy/Caddyfile
else
echo "Caddyfile already exists. Skipping copy."
fi
# Copy default index.html if it does not exist
if [ ! -f /srv/index.html ]; then
echo "index.html not found. Copying default web file..."
cp /defaults/srv/index.html /srv/index.html
else
echo "index.html already exists. Skipping copy."
fi
# Run the original command
exec "$@"
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Welcome to Caddy</title>
<style>
body {
margin: 0;
padding: 0;
font-family: 'Arial', sans-serif;
background: linear-gradient(to bottom right, #f7fafc, #e2e8f0);
color: #2d3748;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
text-align: center;
}
.container {
background: white;
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
border-radius: 10px;
padding: 2rem;
max-width: 600px;
width: 90%;
animation: fadeIn 1s ease-in-out;
}
h1 {
font-size: 2.5rem;
margin-bottom: 1rem;
color: #2c5282;
}
p {
font-size: 1.2rem;
line-height: 1.6;
margin-bottom: 1.5rem;
}
a {
display: inline-block;
padding: 0.8rem 1.5rem;
font-size: 1rem;
color: white;
background-color: #3182ce;
text-decoration: none;
border-radius: 5px;
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
transition: background-color 0.3s ease, transform 0.2s ease;
}
a:hover {
background-color: #2b6cb0;
transform: translateY(-2px);
}
@keyframes fadeIn {
from {
opacity: 0;
transform: translateY(20px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
</style>
</head>
<body>
<div class="container">
<h1>Welcome to Caddy!</h1>
<p>
Your web server is running successfully. This is the default welcome page.
You can customize this page by replacing the <code>index.html</code> file in your server's root directory.
</p>
<a href="https://caddyserver.com/docs" target="_blank">Explore Caddy Documentation</a>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment