forked from getomnico/omni
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCaddyfile
More file actions
169 lines (140 loc) · 4.66 KB
/
Copy pathCaddyfile
File metadata and controls
169 lines (140 loc) · 4.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
# Omni Reverse Proxy Configuration
# Global options
{
# Enable admin API for metrics (optional)
# admin localhost:2019
# Disable admin API in production
admin off
# Email for Let's Encrypt HTTPS certificates
email {$ACME_EMAIL:admin@localhost}
# ACME CA for certificates (use Let's Encrypt staging for testing)
# acme_ca https://acme-staging-v02.api.letsencrypt.org/directory
# HTTP->HTTPS redirect
https_port 443
}
# Import environment variable for domain (defaults to localhost for development)
{$OMNI_DOMAIN:localhost} {
# Logging
log {
output stdout
format json
level INFO
}
# Handle Google webhook notifications (must be before OAuth routes)
handle /google-webhook {
# Rewrite path to connector's webhook endpoint
rewrite /google-webhook /webhook
reverse_proxy google-connector:{$GOOGLE_CONNECTOR_PORT} {
# Health check for the connector
health_uri /health
health_interval 30s
health_timeout 5s
# Headers for webhook notifications
header_up X-Real-IP {remote_host}
header_up X-Forwarded-Proto {scheme}
header_up X-Forwarded-Host {host}
# Preserve all webhook headers from Google
header_up X-Goog-* {>X-Goog-*}
}
}
# Handle Google API endpoints (sync, webhook management)
handle /google/* {
reverse_proxy google-connector:{$GOOGLE_CONNECTOR_PORT} {
health_uri /health
health_interval 30s
health_timeout 5s
header_up X-Real-IP {remote_host}
header_up X-Forwarded-Proto {scheme}
}
}
# Handle Atlassian webhook notifications
handle /webhook/atlassian {
rewrite /webhook/atlassian /webhook
reverse_proxy atlassian-connector:{$ATLASSIAN_CONNECTOR_PORT} {
health_uri /health
health_interval 30s
health_timeout 5s
header_up X-Real-IP {remote_host}
header_up X-Forwarded-Proto {scheme}
header_up X-Forwarded-Host {host}
}
}
# Health check endpoint for monitoring
handle /health {
respond "OK" 200
}
# All other routes go to the SvelteKit web application
handle {
reverse_proxy web:{$WEB_PORT} {
# Load balancing configuration (for future scaling)
lb_policy round_robin
lb_try_duration 5s
lb_try_interval 250ms
# Health checking
health_uri /health
health_interval 10s
health_timeout 3s
health_status 200
# Headers
header_up X-Real-IP {remote_host}
header_up X-Forwarded-For {remote_host}
header_up X-Forwarded-Proto {scheme}
header_up X-Forwarded-Host {host}
# Timeouts
transport http {
read_timeout 60s
write_timeout 60s
dial_timeout 10s
}
}
}
# Response encoding
encode {
gzip
zstd
# Minimum size for compression (1KB)
minimum_length 1024
}
# Security headers
header {
# Remove server header
-Server
# Security headers
X-Content-Type-Options "nosniff"
X-Frame-Options "DENY"
X-XSS-Protection "1; mode=block"
Referrer-Policy "strict-origin-when-cross-origin"
Permissions-Policy "geolocation=(), microphone=(), camera=()"
# HSTS (only for HTTPS)
?Strict-Transport-Security "max-age=31536000; includeSubDomains; preload"
# CSP - adjust based on your needs
Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline'; img-src 'self' data: https:; font-src 'self' data:; connect-src 'self' ws: wss:; frame-ancestors 'none';"
}
# Request size limits
request_body {
# 100MB max request size (for file uploads)
max_size 100MB
}
# Error handling
handle_errors {
@404 {
expression {http.error.status_code} == 404
}
handle @404 {
respond "Page not found" 404
}
@5xx {
expression {http.error.status_code} >= 500
}
handle @5xx {
respond "Internal server error" 500
}
handle {
respond "An error occurred" {http.error.status_code}
}
}
}
# Redirect www to non-www (if using a custom domain)
www.{$OMNI_DOMAIN:localhost} {
redir https://{$OMNI_DOMAIN:localhost}{uri} permanent
}