<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: David Dut</title>
    <description>The latest articles on DEV Community by David Dut (@dutdavid).</description>
    <link>https://dev.to/dutdavid</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F928766%2Fcf00f276-5301-4fa6-905f-807dde3be90e.jpeg</url>
      <title>DEV Community: David Dut</title>
      <link>https://dev.to/dutdavid</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/dutdavid"/>
    <language>en</language>
    <item>
      <title>Hosting a vite project on cloud</title>
      <dc:creator>David Dut</dc:creator>
      <pubDate>Wed, 15 Mar 2023 15:31:14 +0000</pubDate>
      <link>https://dev.to/dutdavid/hosting-a-vite-project-on-cloud-53fb</link>
      <guid>https://dev.to/dutdavid/hosting-a-vite-project-on-cloud-53fb</guid>
      <description>&lt;p&gt;I recently discovered working with vite. vite is a build tool that makes development easy and faster by serving locally during development and bundle your javascript css and other assets together for production. So cool right?&lt;br&gt;
From a react standpoint, I was used to:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

npx create-react-app dut-project
cd dut-project
npm start


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;And your server is up and running. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffd0jb7zoadus1fav8ozk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffd0jb7zoadus1fav8ozk.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
After running the &lt;code&gt;npx create-react-app dut-project&lt;/code&gt;, the build process(You need to be patient as this happens). The command generates 3 folders and 4 files i.e. node_modules, public and src folders with the files being .gitignore, package.json, README.md and package.lock.json. In this process,&lt;br&gt;
Babel transforms the code by adding polyfills which makes your ES2015+ code work with older bowsers.&lt;br&gt;
ESlint is a linter that scans your code against a set of rules and warns you if any rule is violated. There is a lot that happens that we won't delve much into.&lt;br&gt;
The key features of using Create react app are:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;It uses webpack and Babel to bundle the code, that is, the code needs to finish building step by step before you can make changes on the code.&lt;/li&gt;
&lt;li&gt;Create react app provides room for customization especially beneficial when running larger and more complex projects. &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Cloud Deployment&lt;/strong&gt;&lt;br&gt;
I am not going to mention how to do this on cpanel since it's pretty straightforward.&lt;br&gt;
In this guide, my preffered cloud environment is linode.&lt;br&gt;
I am assuming you have already linked your domain to linode&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6yhhy6jxukcaex0sy0xy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6yhhy6jxukcaex0sy0xy.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
ssh into your server&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

ssh user@ip-address/domain


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Once you are logged in, you can install all the required prerequisites like nginx/apache, nodejs, certbot and pm2. You can easily find guide on how to install each of the above mentioned. I preffer using nginx.&lt;/p&gt;

&lt;p&gt;Modify your sites-available to indicate the directory linked to the domain and also where your pm2 logs are going to be accessible.&lt;br&gt;
&lt;code&gt;sudo vim /etc/nginx/sites-available/dutdavid.com&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Paste the following and modify according to how you set up your environment&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

server {

        root /var/www/dutdavid.com/portfolio;
        index index.html index.htm index.nginx-debian.html;

        server_name dutdavid.com;
        access_log /var/log/nginx/nodeapp.log;
        error_log  /var/log/nginx/nodeapp-error.log error;

        location / {
        proxy_pass http://x.x.x.x:xxxx; //indicate IP and port 
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
        }


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Save and test if the changes you made are 'accepted' by nginx&lt;br&gt;
&lt;code&gt;sudo nginx -t&lt;/code&gt;&lt;br&gt;
Restart nginx&lt;br&gt;
&lt;code&gt;sudo systemctl restart nginx&lt;/code&gt;&lt;br&gt;
The next step would be to install certbot to enable ssl on your domain&lt;br&gt;
&lt;code&gt;sudo certbot --nginx -d dutdavid.com&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;That is mandatory process for deploying any static project on linode&lt;br&gt;
Now to make a react project visible on that domain, we will need pm2&lt;br&gt;
Assuming you have already installed pm2, &lt;br&gt;
create ecosystem.config.js file&lt;br&gt;
you can also initialize it. It should look like this &lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

module.exports = {
  apps : [{
    name :"portfolio",
    script : "npm start",
    error_file : "./pm2-error.log",
    out_file : "./pm2-out.log",
  }]
}



&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;To get it started, you simply run &lt;br&gt;
&lt;code&gt;pm2 start ecosystem.config.js&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;These are other commands you can use on pm2&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

pm2 logs //view logs
pm2 dlush // clear logs
pm2 startup ubuntu // keep pm2 running even on reboot
pm2 kill // kill pm2 instance


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Foh9j3ff3dnj51wdea2eg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Foh9j3ff3dnj51wdea2eg.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
You can now access your website using your domain&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Now Lets talk about Vite&lt;/strong&gt;&lt;br&gt;
LiKe I mentioned before, vite is a js build tool that simplifies the way we build front-end web applications. Other tools to do this include webpack that we mentioned above when using create react app. Using webpacks can be slow as it adds more code dependencies. Vite is lightweight development server that is built on top of the native ES modules feature of modern browsers.&lt;br&gt;
It's designed to be fast, simple and easy to use.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Creating and Running Vite Project&lt;/strong&gt;&lt;br&gt;
To create a vite project, you simply need to create a folder eg .viteproject&lt;br&gt;
cd into viteproject then:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

npm create vite@latest
npm install
npm run dev


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;follow the prompts and the project will be created with the default files and folders&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F902d0yau711bcocfdpps.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F902d0yau711bcocfdpps.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The main key features of vite include :&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Vite does not require many configuration or setup and can be used with any framework as seen when creating a vite project, you have the option to choose which framework to use.&lt;/li&gt;
&lt;li&gt;Vite is faster than create react app as it uses the Native ES modules feature of modern browsers eliminating the need for webpack and Babel.&lt;/li&gt;
&lt;li&gt;Has HMR(Hot module Replacement) feature which enables you to make code changes instanly without losing the state of the application.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Deployment on cloud&lt;/strong&gt;&lt;br&gt;
Deploying Vite on cloud is straightforward. Initially I struggled with this because I assumed I'd just use pm2 and everything will just be fine. It did not work 😂. Word of advice, read code documentation. It's not like user manual which we all avoid reading, and assume we'll figure it out along the way.&lt;br&gt;
Anyway, the process is quite simple.&lt;br&gt;
Inside the project folder run:&lt;br&gt;
&lt;code&gt;npm run build&lt;/code&gt;&lt;br&gt;
This should create a dist folder with all the necessary files and folders bundled into a lightweight folder which you can point at in the sites-available configuration file&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flatdbqel7gpxc2zp4xfw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flatdbqel7gpxc2zp4xfw.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
The dist folder is what will be rendered.&lt;br&gt;
Access your domain &lt;a href="https://dutdavid.com" rel="noopener noreferrer"&gt;https://dutdavid.com&lt;/a&gt; and you should see your site.&lt;/p&gt;

&lt;p&gt;In conclusion, both build tools provide a development environment with unique features for development. There are key differences and it's all based on your preferences. Inshort Whatever floats your boat.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>vite</category>
      <category>tutorial</category>
      <category>react</category>
    </item>
    <item>
      <title>wazuh agent as a docker image</title>
      <dc:creator>David Dut</dc:creator>
      <pubDate>Tue, 24 Jan 2023 12:54:09 +0000</pubDate>
      <link>https://dev.to/dutdavid/wazuh-agent-as-a-docker-image-1b5n</link>
      <guid>https://dev.to/dutdavid/wazuh-agent-as-a-docker-image-1b5n</guid>
      <description>&lt;p&gt;one problem I have faced is having different SIEMS monitoring one host device for instance you need different logs from one endpoint device. Having all the agents running on that device could lead to resource contention and potential conflicts. One way around this is have one agent run as a docker container and map the host directories to the docker container directories. In this guide I will be running the wazuh agent in a docker container. For Demo purposes. Both the wazuh manager are deployed in local VM.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;PREREQUISITES&lt;/strong&gt;&lt;br&gt;
I am assuming you already have your wazuh manager running and ready to connect to the agent.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4a8gxsj3wy0k4gxxx45q.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4a8gxsj3wy0k4gxxx45q.PNG" alt="Image description" width="800" height="365"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;PROCEDURE&lt;/strong&gt;&lt;br&gt;
In this guide, my wazuh manager is using the IP address 10.0.2.16 while the agent IP is agent47: 10.0.2.15&lt;/p&gt;

&lt;p&gt;&lt;em&gt;First step is to install docker on the agent&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo apt update
sudo apt install apt-transport-https curl gnupg-agent ca-certificates software-properties-common -y
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable"
sudo apt install docker-ce docker-ce-cli containerd.io -y
sudo usermod -aG docker $USER
newgrp docker
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;check the docker version&lt;br&gt;
&lt;code&gt;docker version&lt;/code&gt;&lt;br&gt;
Ensure docker is running&lt;br&gt;
&lt;code&gt;sudo systemctl status docker&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;If docker is not running for some reason, run the following commands.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo systemctl start docker
sudo systemctl enable docker
sudo systemctl restart docker
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now that docker is installed. The next step is to get the image from docker hub.&lt;br&gt;
One of the challenges I faced was getting the right image. I tried working with noenv but for some reason could not make it work. Shout out to fajarhide for deploying the centos image that worked for me. To pull the image:&lt;br&gt;
&lt;code&gt;docker pull fajarhide/wazuh-agent&lt;/code&gt;&lt;br&gt;
To check the image pulled:&lt;br&gt;
&lt;code&gt;docker images -a&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvza0l3de9k3etmr40668.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvza0l3de9k3etmr40668.PNG" alt="Image description" width="800" height="417"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Running the docker image&lt;/strong&gt;&lt;br&gt;
Now this is the part that got me scratching my head the most.&lt;br&gt;
How well your image will run is determined by the tags you use in this one command &lt;/p&gt;

&lt;p&gt;&lt;code&gt;docker run --network host --env WAZUH_MANAGER_IP='10.0.2.16' -e WAZUH_MANAGER_PORT=1514 -e WAZUH_REGISTRATION_PASSWORD=admin --add-host=agent47:'10.0.2.15' --name wazuh-agent -v /var/log/syslog:/var/log/syslog -v /var/log/auth.log:/var/log/auth.log -v /var/log/dpkg.log:/var/log/dpkg.log -v /var/run/docker.sock:/var/run/docker.sock:ro -v /etc/localtime:/etc/localtime:ro -v /etc/timezone:/etc/timezone:ro fajarhide/wazuh-agent&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;--network host&lt;/strong&gt; this line will enable the image to take the current network interface being used by your device&lt;br&gt;
&lt;strong&gt;-v tag&lt;/strong&gt; this tag is very important. it's used to map various directories you want to scan from to the directories in the docker image.&lt;/p&gt;

&lt;p&gt;check that the docker image is running&lt;br&gt;
&lt;code&gt;docker ps -a&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmmlz3pln3zw0ij7ku8ce.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmmlz3pln3zw0ij7ku8ce.PNG" alt="Image description" width="800" height="418"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When you navigate to agents tag of your wazuh manager, you'll see that your agent is connected.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpckbx1y6ewtzwl867m67.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpckbx1y6ewtzwl867m67.PNG" alt="Image description" width="800" height="383"&gt;&lt;/a&gt;&lt;br&gt;
The final step is to configure ossec.conf to scan varies directories. You can add as many configurations as you want based on what you want to scan i.e vulnerabilities, file integrity etc.&lt;br&gt;
To access the image, you'll need the image ID shown above&lt;/p&gt;

&lt;p&gt;&lt;code&gt;docker exec  -it b031b69b5364 /bin/bash&lt;/code&gt;&lt;br&gt;
You will need to install an editor either vim or nano depending on which works best for you.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;yum update -y
yum install vim
yum install nano
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;vim /var/ossec/etc/ossec.conf&lt;/code&gt;&lt;br&gt;
edit the ossec.conf file and configure it according to your needs.&lt;br&gt;
This is the minimal configurations I used&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;ossec_config&amp;gt;
  &amp;lt;client&amp;gt;
    &amp;lt;server&amp;gt;
      &amp;lt;address&amp;gt;10.0.2.16&amp;lt;/address&amp;gt;
      &amp;lt;port&amp;gt;1514&amp;lt;/port&amp;gt;
      &amp;lt;protocol&amp;gt;tcp&amp;lt;/protocol&amp;gt;
    &amp;lt;/server&amp;gt;
    &amp;lt;config-profile&amp;gt;centos, centos7, centos7.9&amp;lt;/config-profile&amp;gt;
    &amp;lt;notify_time&amp;gt;10&amp;lt;/notify_time&amp;gt;
    &amp;lt;time-reconnect&amp;gt;60&amp;lt;/time-reconnect&amp;gt;
    &amp;lt;auto_restart&amp;gt;yes&amp;lt;/auto_restart&amp;gt;
    &amp;lt;crypto_method&amp;gt;aes&amp;lt;/crypto_method&amp;gt;
  &amp;lt;/client&amp;gt;

  &amp;lt;client_buffer&amp;gt;
    &amp;lt;!-- Agent buffer options --&amp;gt;
    &amp;lt;disabled&amp;gt;no&amp;lt;/disabled&amp;gt;
    &amp;lt;queue_size&amp;gt;5000&amp;lt;/queue_size&amp;gt;
    &amp;lt;events_per_second&amp;gt;500&amp;lt;/events_per_second&amp;gt;
  &amp;lt;/client_buffer&amp;gt;
&amp;lt;!-- Policy monitoring --&amp;gt;
&amp;lt;rootcheck&amp;gt;
    &amp;lt;disabled&amp;gt;no&amp;lt;/disabled&amp;gt;
    &amp;lt;check_files&amp;gt;yes&amp;lt;/check_files&amp;gt;
    &amp;lt;check_trojans&amp;gt;yes&amp;lt;/check_trojans&amp;gt;
    &amp;lt;check_dev&amp;gt;yes&amp;lt;/check_dev&amp;gt;
    &amp;lt;check_sys&amp;gt;yes&amp;lt;/check_sys&amp;gt;
    &amp;lt;check_pids&amp;gt;yes&amp;lt;/check_pids&amp;gt;
    &amp;lt;check_ports&amp;gt;yes&amp;lt;/check_ports&amp;gt;
    &amp;lt;check_if&amp;gt;yes&amp;lt;/check_if&amp;gt;

  &amp;lt;!-- Frequency that rootcheck is executed - every 12 hours --&amp;gt;
  &amp;lt;frequency&amp;gt;43200&amp;lt;/frequency&amp;gt;

  &amp;lt;rootkit_files&amp;gt;etc/shared/rootkit_files.txt&amp;lt;/rootkit_files&amp;gt;
  &amp;lt;rootkit_trojans&amp;gt;etc/shared/rootkit_trojans.txt&amp;lt;/rootkit_trojans&amp;gt;

  &amp;lt;skip_nfs&amp;gt;yes&amp;lt;/skip_nfs&amp;gt;
&amp;lt;/rootcheck&amp;gt;
&amp;lt;syscheck&amp;gt;
   &amp;lt;directories check_all="yes" realtime="yes"&amp;gt;/home/dut&amp;lt;/directories&amp;gt;
&amp;lt;/syscheck&amp;gt;
  &amp;lt;localfile&amp;gt;
    &amp;lt;log_format&amp;gt;syslog&amp;lt;/log_format&amp;gt;
    &amp;lt;location&amp;gt;/var/ossec/logs/active-responses.log&amp;lt;/location&amp;gt;
  &amp;lt;/localfile&amp;gt;

  &amp;lt;localfile&amp;gt;
    &amp;lt;log_format&amp;gt;syslog&amp;lt;/log_format&amp;gt;
    &amp;lt;location&amp;gt;/var/log/auth.log&amp;lt;/location&amp;gt;
  &amp;lt;/localfile&amp;gt;

  &amp;lt;localfile&amp;gt;
    &amp;lt;log_format&amp;gt;syslog&amp;lt;/log_format&amp;gt;
    &amp;lt;location&amp;gt;/var/log/syslog&amp;lt;/location&amp;gt;
  &amp;lt;/localfile&amp;gt;

  &amp;lt;localfile&amp;gt;
    &amp;lt;log_format&amp;gt;syslog&amp;lt;/log_format&amp;gt;
    &amp;lt;location&amp;gt;/var/log/dpkg.log&amp;lt;/location&amp;gt;
  &amp;lt;/localfile&amp;gt;
&amp;lt;global&amp;gt;
&amp;lt;fim_daemon&amp;gt;yes&amp;lt;/fim_daemon&amp;gt;
&amp;lt;/global&amp;gt;
&amp;lt;sca&amp;gt;
    &amp;lt;enabled&amp;gt;yes&amp;lt;/enabled&amp;gt;
    &amp;lt;scan_on_start&amp;gt;yes&amp;lt;/scan_on_start&amp;gt;
    &amp;lt;interval&amp;gt;12h&amp;lt;/interval&amp;gt;
    &amp;lt;skip_nfs&amp;gt;yes&amp;lt;/skip_nfs&amp;gt;
&amp;lt;/sca&amp;gt;
&amp;lt;wodle name="syscollector"&amp;gt;
   &amp;lt;disabled&amp;gt;no&amp;lt;/disabled&amp;gt;
   &amp;lt;interval&amp;gt;1h&amp;lt;/interval&amp;gt;
   &amp;lt;os&amp;gt;yes&amp;lt;/os&amp;gt;
   &amp;lt;packages&amp;gt;yes&amp;lt;/packages&amp;gt;
   &amp;lt;hotfixes&amp;gt;yes&amp;lt;/hotfixes&amp;gt;
&amp;lt;/wodle&amp;gt;
&amp;lt;/ossec_config&amp;gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I'm assuming you already know how to work with the ossec.conf file&lt;/p&gt;

&lt;p&gt;Save and exit the editor&lt;/p&gt;

&lt;p&gt;Exit and restart the container&lt;/p&gt;

&lt;p&gt;Now your wazuh manager should be able to show the various security events.&lt;/p&gt;

</description>
      <category>virtualmachine</category>
      <category>containers</category>
      <category>tutorial</category>
      <category>learning</category>
    </item>
    <item>
      <title>Load Balancing with Golang</title>
      <dc:creator>David Dut</dc:creator>
      <pubDate>Mon, 19 Sep 2022 11:29:43 +0000</pubDate>
      <link>https://dev.to/dutdavid/load-balancing-with-golang-17jh</link>
      <guid>https://dev.to/dutdavid/load-balancing-with-golang-17jh</guid>
      <description>&lt;p&gt;Load balancing is the process of efficiently distributing incoming network traffic across a group of backend servers.&lt;br&gt;
In an instance where there are constant requests from users mostly common with banking systems etc, having a traffic ‘cop’ in between the user requests goes a long way to efficiently maximize the requests to maximize on speed and capacity utilization to ensure no server is overworked. If one server goes down, the load balancer redirects traffic to the remaining online servers.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg9kcn4jxzczbuftwn0lk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg9kcn4jxzczbuftwn0lk.png" alt=" " width="800" height="686"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the above instance, when a user makes a request, it goes through the load balancer to determine which server is available.&lt;br&gt;
A reverse proxy is required in this as well for security. We are using the http util package to create the reverse proxy. The reverse proxy redirects the request while hiding the address of the server&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;type simpleServer struct {
    addr  string
    proxy *httputil.ReverseProxy
}

func newSimpleServer(addr string) *simpleServer {
    serverUrl, err := url.Parse(addr)
    handleErr(err)

    return &amp;amp;simpleServer{
        addr:  addr,
        proxy: httputil.NewSingleHostReverseProxy(serverUrl),
    }
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The loadbalancer will be implemented as a struct with a port, server and roundrobincount to check between the alive servers.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;type LoadBalancer struct {
    port            string
    roundRobinCount int
    servers         []Server
}

func NewLoadBalancer(port string, servers []Server) *LoadBalancer {
    return &amp;amp;LoadBalancer{
        port:            port,
        roundRobinCount: 0,
        servers:         servers,
    }
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We also create a function to create a new loadbalancer and server based on the struct.&lt;/p&gt;

&lt;p&gt;We have 2 methods&lt;br&gt;
isAlive method checks if the server is up or not and &lt;br&gt;
Get address method to get address of the server&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;func (s *simpleServer) Address() string { return s.addr }

func (s *simpleServer) IsAlive() bool { return true }

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;An overview of this;&lt;/p&gt;

&lt;p&gt;We have a main function which creates a server list and calls the server proxy function to get the next available server. Thus checks if the server is alive through roundrobin&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
