I'm leaving here the Nginx configuration I used that I figured out with the help of given answers.
First you'll need the latest NGINX Open Source compiled with the --with-stream
and with-stream_ssl_module
configuration parameters
Check your system with:
nginx -V 2>&1 | tr ' ' '\n' | grep stream
Next, inside /etc/nginx edit the nginx.conf file and append to the bottom:
include /etc/nginx/streams-enabled/*;
Create that folder if it doesn't exist
$ sudo mkdir /etc/nginx/streams-enabled
Create a file inside sites-available and name it what ever you want. eg. logstash.proxy
Edit the file and add the following basic configuration
stream {
upstream logstash {
server 127.0.0.1:5044;
}
server {
listen 5544 ssl;
proxy_pass logstash;
# SSL
ssl_certificate /etc/letsencrypt/live/YOURDOMAIN/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/YOURDOMAIN/privkey.pem;
}
}
Symlink that file into the streams-enabled folder
$ sudo ln -s /etc/nginx/sites-enabled/logstash.proxy /etc/nginx/streams-enabled/logstash-proxy
Test nginx with the nginx -t
command. If everything's fine, you should be able to restart Nginx with this configuration and your beats will be able to communicate with your Logstash instance.
There are more steps to do with Logstash and *beats configurations, but the above should cover the Nginx part.
Please be careful with the above and don't use it in Production. It is only meant for education and fiddling around.
if you want to use it on a publicly accessible system (DigitalOcean, Linode, Whatever...), you should have a firewall up and only allow the machines running the beats through.
// Ubuntu with ufw
$ sudo ufw allow from your.beats.ip.address to any port 5544 proto tcp // or any port you used above
$ sudo ufw reload
$ sudo ufw status
Status: active
To Action From
-- ------ ----
5544/tcp ALLOW your.beats.ip.address