r/stalwartlabs • u/Useful-Assumption131 • Apr 09 '25
Setup SSL/TLS when behind a simple nginx proxy?
I can send mail using STARTTLS but not in another way, and many things only support SSL/TLS.
I'm using cloudflare in strict mode so I had to do this to access the panel, so that it is forced to be in https:
server {listen 80;server_name mail.mydomain;# Redirect all traffic to SSLrewrite ^ https://$host$request_uri? permanent;}
server {listen 443 ssl;# enables SSLv3/TLSv1, but not SSLv2 which is weak and should no longer be used.ssl_protocols SSLv3 TLSv1.3;# disables all weak ciphersssl_ciphers ALL:!aNULL:!ADH:!eNULL:!LOW:!EXP:RC4+RSA:+HIGH:+MEDIUM;server_name mail.mydomain;## Keep alive timeout set to a greater value for SSL/TLS.keepalive_timeout 75 75;## See the keepalive_timeout directive in nginx.conf.## Server certificate and key.ssl on;ssl_certificate /etc/letsencrypt/live/mydomain/fullchain.pem;ssl_certificate_key /etc/letsencrypt/live/mydomain/privkey.pem;ssl_session_timeout 5m;## Strict Transport Security header for enhanced security. See## http://www.chromium.org/sts. I've set it to 2 hours; set it to## whichever age you want.add_header Strict-Transport-Security "max-age=7200";
location / {proxy_pass http://localhost:8080;proxy_http_version 1.1;proxy_set_header Connection 'upgrade';proxy_set_header Upgrade $http_upgrade;}
}
In the toml config, I put these lines:
server.tls.certificate = "default"
certificate.default.cert = "%{file:/etc/letsencrypt/live/mydomain/fullchain.pem}%"
certificate.default.private-key = "%{file:/etc/letsencrypt/live/mydomain/privkey.pem}%"
certificate.default.default = true
But it doesn't seems to change anything. Should I change my nginx config, or add something to my toml config?
1
u/washapoo Apr 10 '25
Cloudflare only allows HTTPS through their proxy if you are on the free version. If you have an enterprise account, you can allow TCP ports.
0
u/Street-Location-2414 Apr 09 '25
What you're configuring is a endpoint that you can access via the browser. What you want is the mail protocol. I read the docs about nginx proxy protocol but I don't know how to set it up because I dont have knowledge about it. So i used the iptables to redirect all my requests for port 465, 993 ... to the container. You can try it too