目前Caddy尚不支持uwsgi协议,因此需要安装Gunicorn来连接caddy和flask
pip install gunicorn
xxxxxxxxxxmkdir testvim test/test.py
xfrom flask import Flaskapp = Flask(__name__)@app.route("/")def hello():return "<h1 style='color:blue'>Hello There!</h1>"if __name__ == "__main__":app.run()
xxxxxxxxxxvim test/wsgi.py
xxxxxxxxxxfrom test import appif __name__ == "__main__":app.run()
xxxxxxxxxxcd testgunicorn -b "127.0.0.1:8000" wsgi:app
xxxxxxxxxxvim /etc/caddy/Caddyfile
xxxxxxxxxxtest.wofost.com {root /data/www/wofost.com/testproxy / localhost:8000 {transparent}}
xxxxxxxxxxsystemctl restart caddy.service
xxxxxxxxxxyum install psmiscpstree -ap|grep gunicornkill -HUP **** #restartkill -9 **** #shutdown