Skip to content

Instantly share code, notes, and snippets.

@twnaing

twnaing/Caddyfile

Created Jul 3, 2020
Embed
What would you like to do?
Caddyfile v2 for Ruby on Rails application
# save Caddyfile in rails app root folder
# run rails server with port 4000 in one terminal
$ bundel exec rails server -p 4000 -b 127.0.0.1
# run caddy in another terminal
CADDY_HOST=localhost CADDY_PORT=3000 CADDY_BACKEND_PORT=4000 caddy run -config Caddyfile
http://{$CADDY_HOST}:{$CADDY_PORT} {
root * ./public
@notStatic {
not {
file {
try_files {path}
}
}
}
reverse_proxy @notStatic {
to localhost:{$CADDY_BACKEND_PORT}
header_up X-Real-IP {remote_host}
header_up X-Forwarded-Proto {scheme}
header_up Access-Control-Allow-Origin *
header_up Access-Control-Allow-Credentials true
header_up Access-Control-Allow-Headers Cache-Control,Content-Type
transport http {
read_buffer 8192
}
}
file_server
}
@twnaing

This comment has been minimized.

Copy link
Owner Author

@twnaing twnaing commented Jul 3, 2020

Adapt most of the config from this URL

@twnaing

This comment has been minimized.

Copy link
Owner Author

@twnaing twnaing commented Jul 3, 2020

for Caddyfile v1, check this out

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment