1. Caddy version (caddy version
):
v2.3.0 h1:fnrqJLa3G5vfxcxmOH/+kJOcunPLhSBnjgIvjXV/QTA=
2. How I run Caddy:
a. System environment:
Ubuntu 20.04
b. Command:
caddy run --config ~/Caddyfile
c. Service/unit/compose file:
# None
d. My complete Caddyfile or JSON config:
:80 {
root * /root/test/frontend/build
file_server
encode gzip
reverse_proxy /api* localhost:5000
log {
output file /var/log/caddy/access.log {
roll_size 1mb
roll_keep 4
roll_keep_for 24h
}
}
}
3. The problem I’m having:
I am trying to seek advice/recommendation on how my Caddyfile
should be set up. The above Caddyfile
appears to do what I want based on some brief testing, but I am new to Caddy and would love to learn more from you.
My project consists of a React frontend app listening to port 3000 and a Python Flask app served by a Gunicorn server on port 5000. The React app (to be at https://mydomain.com
) queries the Flask API server (to be at https://mydomain.com/api
to retrieve data. No domain name has been purchased yet for this project, but I will get one real soon!
Several questions:
-
Should Caddyfile use
reverse_proxy /api* localhost:5000
or
reverse_proxy /api* 0.0.0.0:5000
Both appears to work in my case.
-
Does the
file_server
directive apply/pair only toroot * /root/test/frontend/build
? Or is it also being applied to thereverse_proxy
directive? If it is applied toreverse_proxy
directive, should this be a concern? -
The API server listening on port 5000 is a Python Flask app being served using Gunicorn HTTP server. Does it make sense to replace Gunicorn with Caddy’s
file_server
? Is there a significant performance difference between Gunicorn and Caddy’sfile_server
?