Score:0

Limit number of connection for a special port on Linux server

bz flag

I have an Nginx server in Ubuntu 20, And has a multi-port listener on it for the proxy pass.

I want to limit the number of connections per port. IP doesn't matter (I mean dont limit by IP). My IPTable has been disabled and I prefer to dont use it. I want way to limit connection event without Nginx but the Nginx limit is ok too.

There is a way to limit that without lose performance ?

Update : I found CSF Firewall can manegment this but there is easier way to Im locking for?

Nikita Kipriyanov avatar
za flag
What are you planning to do with the connections that exceed the limit? Easiest is to drop them, in which case the firewall way of limiting is certainly looks the most straightforward. The "CSF firewall" is nothing more that the script which uses iptables under the hood, but it is definitely much more hassle than write just one iptables command. In general, if you are in Linux and want to use the firewall, you won't be able to avoid using Netfilter, either with iptables or nftables. Finally, I've found [your question answered](https://access.redhat.com/solutions/396273).
Mohsen avatar
bz flag
@NikitaKipriyanov Thank you, that so good answer
cn flag
@NikitaKipriyanov The suggested answer limits the number of connections per IP, not the total number of connections.
A.B avatar
cl flag
A.B
@x-yuri if you really understand the answer in the link, you should be able to figure out the additional parameter to get it working as intended.
cn flag
@A.B One might say, if you know what `iptables` is you should be able to figure out how to achieve the goal. Anyways, I've found [the question answered](https://serverfault.com/a/547317/162443).
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.