Could this be a new functionality for sslh? Or has anybody ideas, what to use? #458
Replies: 8 comments 1 reply
-
I am not sure I follow everything you're trying to do, but:
to work: with appropriate service definitions in
and then every time sslh forwards to Does this help? |
Beta Was this translation helpful? Give feedback.
-
Hi again, I am a step further, after looking into your source. In common.c you describe the issue, as it looks, you found that happening with stunnel also. This is something, I guessed, that this could be the problem. It should be no issue, if sslh is connecting from With the 'IP_BIND_ADDRESS_NO_PORT' option, this situation could be avoided, and the connection can be established. With this option, the test against potential conflicts is done first, when establishing the connection, and the validity of the four-way-tuple can be checked. And as long, as not both applications will connect to the same target, there will be no longer a problem. 90 minutes later: This would be similar to the connectx function, Cloudflare mentions. So in in first try, SO_REUSEADDR would make it possible, to reuse also the clients port number, and if that fails, IP_BIND_ADDRESS_NO_PORT would give the second option better cards. Will sleep over it and look again tomorrow. But from my current understanding the change would be not more, than just two adapted setsockopt() lines. |
Beta Was this translation helpful? Give feedback.
-
It will not go out of my head, so I just did those changes and will give them a try the next days.
|
Beta Was this translation helpful? Give feedback.
-
Damn, fighting at another front:
but: the problem consist. Going back to my distribution binary, transparency works, even without any capabilities on the binary. |
Beta Was this translation helpful? Give feedback.
-
While I had first my setup in this way, as this is the setup, I need for my idea to become real
I tried now with changed roles, and had sslh (the distribution binary) doing the job as frontman, and assigned nginx to the second row:
This is working fine and Openresty/nginx doing its homework perfect and second in chain:
As you can see, the client IP:PORT combinations stays the same through the chain, as the 4-value-tuple is always different. That looks like, that it may be worth, to dig into the code of nginx, as they seem to do the things in a good way. Unfortunately, for my solution, I need nginx in the first row, and sslh behind. From the theory, coming from the Cloudflare article, my idea what to change, should work. But unfortunately, all my tries to compile a own sslh will fail, because the binary gets transparency denied :-( What I am doing wrong? Why can't the self-compiled binaries can't go transparent? Is there a configuration file missing? I may miss a very obvious thing, but i have currently no clue. |
Beta Was this translation helpful? Give feedback.
-
OK, looks like I have found the reason: I am starting sslh with the parameter |
Beta Was this translation helpful? Give feedback.
-
Ok, besides the problem, why the "--user" parameter is not working, I am able to run the modified sslh without any problems behind nginx. I did another test with stunnel, and yes: stunnel is also buggy. When stunnel runs in front of the modified sslh, everything is fine. But the other way round, the connections are failing as stunnel can't solve the conflict, with the ip-address sslh has already bound to dummy0. The good news: nginx can do everything, stunnel does as well and works in both positions. For just having an proxytunnel-endpoint, both variants (the native nginx and openresty) will do the job. |
Beta Was this translation helpful? Give feedback.
-
OK, closing this discussion, as I have a solution with my proposed fix to sslh. As soon, as sslh can be used at any position in a daisy-chain of ip-transparent applications, my openresty sultion works. |
Beta Was this translation helpful? Give feedback.
-
Hello,
I am still in process upgrading old server configurations, make them stable and reach a better level of functionality.
Currently I am dealing with fail2ban, and I am unhappy, that the reaction a fail2ban block just looks like a broken server. That will be still no issue for 90-99% of the connections, beeing blocked by this way, but it will affect real users/customers/... as well. Especially, when the block occurs after 2 or 3 fails. So my current idea is, having a fail2ban instance, which has no banaction, but filters the log an fills its database with the result. Now I am able for example in exim, to deny incoming connections immediately, but with an error message, telling that this connection is blocked because of... and for so long ... and e.g. an additional information, how to fix
With this configuration, I protect the application against most of the usual threats, as I don't accept any data, which could lead to an exploit/account hack/...
But legit users will know, why they are blocked. Now I can run a second fail2ban jail, which just reads the related logs to this block (a very leightweight RegEx), and do the usual firewall block, but now for a real longer time. This allows differentation between legit clients, which will follow rules, posted in the deny message, and therefore not longer appearing with higher numbers in the log and those, who really earn beeing blocked for long.
Ok, this works fine with exim but when I looked at dovcot, it figured out, that dovecot does not support dnsbl/rbl or any other dynamic feedback mechanism, checking if a IP address should be denied.
Ok, I thought: No problem, let me use nginx as proxy, this is capable of transparent proxying like sslh and supports many protocols. So I guessed, this could be my swiss army knife, to fix all those applications, not able to talk to sql-databses or dns servers. Next big dissapointment: nginx supports this possibilities only in paid plus edition. So much for FOSS ...
So I am coming back to think: May it be a possible addition for sslh, that it can do decisions, based on the incoming ip and dnsbl queries, which target to be adressed? Doing this, I could define dummy targets, which will just give a short information, that the service is currently unavailable, and sslh will decide, whether to connect to the real or to the dummy target.
This could be adapted in a way, that sslh may listen of several incoming addresses/ports, and the routing decision can be just made for the incoming connection.
E.g.
If sslh would listen on ports 110 (pop3), 143 (imap2), 993 (imaps) and 995 (pops)
the target would either be the real dovecot or the fake dovecot, telling that no connections possible.
This service would be complete protocol agnostic, as decisions are only made on the source ip and destination port. Therefore it would help for almost any application.
The disadvantage is, that you need to configure dummy-applications, which are either configuration clones of the real application, or some stunnels to simple scripts, just answering to the first protocol command.
If anybody has better ideas, I really would glad to hear!
Beta Was this translation helpful? Give feedback.
All reactions