Hey everyone,
ERPNEXT with Caddy… spent enough time on this. Findings below:
First Working Caddyfile
{
email YOUREMAIL
}
YOURDOMAIN {
root * /home/YOURUSER/frappe-bench/sites
file_server
handle {
reverse_proxy http://127.0.0.1:8000
}
@staticFiles {
file {
try_files {path} /YOURDOMAIN/public{path} /YOURDOMAIN/public{path}/index.html
}
}
handle @staticFiles {
rewrite * {http.matchers.file.relative}
}
@protected {
path_regexp ^/protected/.*
}
handle @protected {
rewrite * /YOURDOMAIN/{http.regexp.0}
}
@502 {
expression {http.error.status_code} == 502
}
rewrite @502 /502.html
handle @502 {
file_server
}
encode gzip
}
=====================
Below NOT Working, trying to match erpnext nginx output.
{
email YOUREMAIL
}
YOURDOMAIN {
root * /home/YOURUSER/frappe-bench/sites
header {
X-Frame-Options "SAMEORIGIN"
Strict-Transport-Security "max-age=63072000; includeSubDomains; preload"
X-Content-Type-Options "nosniff"
X-XSS-Protection "1; mode=block"
Referrer-Policy "same-origin, strict-origin-when-cross-origin"
}
@protected {
path_regexp ^/protected/.*
}
@htmlFiles {
file {
try_files {path}/index.html {path}.html {path}/ /YOURDOMAIN//public{uri}
}
}
@fileDownloads {
path_regexp ^/files/.*\.(htm|html|svg|xml)
}
handle @protected {
rewrite * /YOURDOMAIN/{http.regexp.0}
}
handle @htmlFiles {
rewrite * {http.regexp.0}
}
handle @fileDownloads {
rewrite * /YOURDOMAIN/public{uri}
header {
Content-disposition "attachment"
}
}
handle {
reverse_proxy http://127.0.0.1:8000
}
@socketio {
path /socket.io
}
handle @socketio {
reverse_proxy http://127.0.0.1:9000
}
@502 {
expression {http.error.status_code} == 502
}
rewrite @502 /502.html
handle @502 {
file_server
}
file_server
encode gzip
}
=============
hope that helps anyone searching. is there anything i’m missing ??
cheers