prismodial
prismodial2w ago

Solved - Is it possible to use nginx as my reverse proxy and still use "email triggers?"

I'm running Windmill on a DO box (Ubuntu 22.04) that's hosting some other apps, and I'm using nginx to route requests to all the apps. Everything is working great except I can't get emails to post into Windmill. From what I'm seeing, nginx is registering emails the server is receiving. As soon as it tries to send it to Windmill though, the connection is immediately closed. That's what I'm gathering from looking at nginx's logs and this testing tool at least. Not sure if this is the right place to ask. I know I'm not using Caddy directly, which is the default setup. But is this something someone can help with? Let me know and I'll post my full configuration files.
4 Replies
fjørdlek
fjørdlek7d ago
You just have to proxy TCP 25 -> 2525 basically configure nginx to do:
# This is caddy rule
{
layer4 {
:25 {
proxy {
to windmill_server:2525
}
}
}
}
# This is caddy rule
{
layer4 {
:25 {
proxy {
to windmill_server:2525
}
}
}
}
which I think would be something like:
stream {
server {
listen 25; # Listen on port 25 (SMTP)
proxy_pass windmill_server:2525; # Forward connections to windmill_server:2525
}
}
stream {
server {
listen 25; # Listen on port 25 (SMTP)
proxy_pass windmill_server:2525; # Forward connections to windmill_server:2525
}
}
in nginx you might need to install nginx-stream
prismodial
prismodialOP6d ago
Yes! I actually figured this out on my own, but yep, that's pretty much what I had to do. This was the nginx settings in nginx.conf that ended up working:
{
server
{
listen 25;
proxy_pass 127.0.0.1:6025;
}
}
{
server
{
listen 25;
proxy_pass 127.0.0.1:6025;
}
}
and in my docker compose file, I had to expose the port of course:
windmill_server:
...
image: ${WM_IMAGE}
ports:
- 6025:2525
- 6080:8000
...
windmill_server:
...
image: ${WM_IMAGE}
ports:
- 6025:2525
- 6080:8000
...
where windmill (via docker) and nginx are running on the same server. One thing that had me running in circles for a long time was A) messing around with nginx's mail configuration and B) being on an outdated version of nginx. For anyone else, as far as I can tell, you must use nginx's stream setting, not mail. With the mail setting, I believe the only way to get nginx to serve that is by adding an authentication server via the auth_http setting. I tried probably 4 options (link) to create that server, and I could not for the life of me get data sent from the authentication server to windmill. Even with no security settings, all open connections, etc, etc. So use the stream setting and make sure you're on at least nginx version 1.19.4. While previous versions have the stream setting, they won't fully pass mail server data using it, leading to some headaches. Our server was actually on a previous version of Ubuntu (22.04) too which only hosts nginx 1.18.0 by default in the package manager. That was causing the biggest issue. I ended up having to compile from source Hopefully that all will help someone else down the road. Thanks for the reply Alex. Even if I had saw it earlier, I still needed to get the right version of nginx ha!
fjørdlek
fjørdlek6d ago
👍 thanks for sharing! I'll add a nginx.conf template file to the repo with your comments!
prismodial
prismodialOP6d ago
Nice. That's great to hear. No problem, glad I was able to keep my current layout and get windmill running

Did you find this page helpful?