Caddyfile syntax for uwsgi server/Flasp-App

Hello,

I have a uwsgi server for my Flaskapp wich is running in a docker container and listening to port 3000. I am using this module to proxy to my wusgi server (https://caddyserver.com/docs/modules/http.reverse_proxy.transport.uwsgi#github.com/BadAimWeeb/caddy-uwsgi-transport)

My uwsgi.ini looks like this:

[uwsgi]

; Execute the ./{module}.py file.
module = tickets
; The {callable} global variable inside the {module}.py file is treated as the Flask instance.
callable = app

; Automatic generation of log files.
daemonize = /usr/local/var/log/uwsgi-@(exec://date +%%Y-%%m-%%d).log
log-reopen = true
log-maxsize = 8000000
logfile-chown = on
logfile-chmod = 644

; Specify the user and group for executing uWSGI.
uid = root
gid = root
master = true
process = 1
; Filename containing the process ID.
pidfile = /usr/local/var/run/app.pid

; Clear the .pid file if the previous exit was abnormal?
vacuum = true
; Force termination upon receiving the TERM signal?
die-on-term = true
; Force termination of processes that do not respond within the specified seconds.
harakiri = 30
; If uWSGI should automatically reload this configuration file when edited, set to 1.
py-autoreload = 1

; If using nginx, specify the port number to use as a socket.
http = :3000

and my Caddyfile like this;

my.domain.name {
    reverse_proxy {
        to uwsgi_docker:3000 {
            transport uwsgi {
                uwsgi_param UWSGI_INI /pathto/uwsgi.ini
            }
        }
    }
}

I am unsure about the syntax of that Caddyfile and if I have used that correctly. In my uwsgi.ini file I have tried using “socket = :3000” and “http = :3000”.
Also, I am unsure if the path to my uswgi is set correctly. I have tried using the path to it within my uwsgi_docker conatiner.

Thank you

to doesn’t take a block. transport and to are siblings of eachother. See the official docs for the reverse_proxy syntax: reverse_proxy (Caddyfile directive) — Caddy Documentation

You can move your upstream address to be inline instead of using to, shorter config:

my.domain.name {
	reverse_proxy uwsgi_docker:3000 {
		transport uwsgi {
			uwsgi_param UWSGI_INI /pathto/uwsgi.ini
		}
	}
}
1 Like

Thank you, worked like a charm :slight_smile:

1 Like

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