Created
July 3, 2020 08:37
-
-
Save twnaing/4012b8817d191bc15ee5853e513c2689 to your computer and use it in GitHub Desktop.
Caddyfile v2 for Ruby on Rails application
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Adapt most of the config from this URL