Erpnext with Caddy v2

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

Please fill out the help topic template as per the forum rules. You posted in the wrong category originally.

I apologize everyone.

Please click on New Topic, select the Help category, and you’ll see the help topic template in the text box. Copy that template, make a new comment in this thread, and fill out the template.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.