<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Archiwa Linux - soban</title>
	<atom:link href="https://soban.pl/category/linux/feed/" rel="self" type="application/rss+xml" />
	<link>https://soban.pl/category/linux/</link>
	<description>IT, Linux, Servers, Security</description>
	<lastBuildDate>Thu, 26 Feb 2026 12:28:02 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.1</generator>
	<item>
		<title>Fail2Ban: How to Detect Repeat Offenders and Ban Them for a Week (Recidive)</title>
		<link>https://soban.pl/fail2ban-recidive-nginx-wordpress-setup/</link>
		
		<dc:creator><![CDATA[soban]]></dc:creator>
		<pubDate>Thu, 26 Feb 2026 12:09:28 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<guid isPermaLink="false">https://soban.pl/?p=752</guid>

					<description><![CDATA[<p>If you use Fail2Ban with Nginx and WordPress, sooner or later you’ll notice one thing: the same IP addresses keep coming back. They get banned for a few minutes or an hour, disappear… and shortly after try again /.env, /wp-login.php, /phpmyadmin, or other common attack paths. The solution is not to aggressively tighten the filters. [&#8230;]</p>
<p>Artykuł <a href="https://soban.pl/fail2ban-recidive-nginx-wordpress-setup/">Fail2Ban: How to Detect Repeat Offenders and Ban Them for a Week (Recidive)</a> pochodzi z serwisu <a href="https://soban.pl">soban</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<figure class="wp-block-image size-large is-resized"><img fetchpriority="high" decoding="async" width="1024" height="688" src="https://soban.pl/wp-content/uploads/2026/02/image-3-1024x688.png" alt="" class="wp-image-749" style="width:566px;height:auto" srcset="https://soban.pl/wp-content/uploads/2026/02/image-3-1024x688.png 1024w, https://soban.pl/wp-content/uploads/2026/02/image-3-300x201.png 300w, https://soban.pl/wp-content/uploads/2026/02/image-3-768x516.png 768w, https://soban.pl/wp-content/uploads/2026/02/image-3.png 1157w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p><br>If you use Fail2Ban with Nginx and WordPress, sooner or later you’ll notice one thing: the same IP addresses keep coming back. They get banned for a few minutes or an hour, disappear… and shortly after try again <code>/.env</code>, <code>/wp-login.php</code>, <code>/phpmyadmin</code>, or other common attack paths.</p>



<p>The solution is not to aggressively tighten the filters. The solution is <strong>recidive</strong> — a second layer of protection in Fail2Ban that analyzes the ban history and blocks repeat offenders long-term.</p>



<h2 class="wp-block-heading">Reference to the previous configuration</h2>



<p>If you don’t yet have a basic Fail2Ban configuration for Nginx and WordPress, I described it here:</p>



<p><a href="https://soban.pl/fail2ban-nginx-wordpress-setup-2/" target="_blank" rel="noopener">Fail2Ban + Nginx + WordPress – basic configuration</a></p>



<p>In that article, we configure jails such as <code>nginx-exploit</code>, <code>nginx-secure</code>, and <code>sshd</code>. Recidive does not replace that configuration — it strengthens it.</p>



<h2 class="wp-block-heading">How to find repeat offenders in the logs</h2>



<p>First, it’s worth checking whether the issue actually exists. We extract from the Fail2Ban logs the list of IP addresses that were banned most frequently:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">grep "Ban " /var/log/fail2ban.log | awk '{print $NF}' | sort | uniq -c | sort -nr | head</pre></div>



<p>Example output (addresses partially anonymized):</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">13 204.76.203.18
9 41.142.XXX.XXX
8 64.89.XXX.XXX
8 50.82.XXX.XXX
8 35.243.XXX.XXX
8 34.24.XXX.XXX
7 45.166.XXX.XXX
7 34.83.XXX.XXX
7 176.42.XXX.XXX
6 49.36.XXX.XXX</pre></div>



<p>If you see numbers like 8, 9, or 13 — it means those IPs are coming back after the ban expires. A short <code>bantime</code> is just a technical pause for them.</p>



<h2 class="wp-block-heading">Why recidive is better than increasing bantime</h2>



<ul class="wp-block-list">

<li>You don’t have to ban everyone for 24 hours because of a single typo in a URL.</li>



<li>You don’t increase the risk of blocking legitimate users.</li>



<li>The penalty is progressive and applies only to returning addresses.</li>

</ul>



<p>Recidive analyzes <code>/var/log/fail2ban.log</code> and counts how many times a given IP has been banned by other jails. This way, you only “finish off” those that have already been blocked multiple times before.</p>



<h2 class="wp-block-heading">Recidive configuration (5 bans in 24h = 7 days ban)</h2>



<p>Add the following block to <code>/etc/fail2ban/jail.local</code>:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">nano /etc/fail2ban/jail.local</pre></div>



<p>At the end of the file, paste:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">[recidive]
enabled  = true
logpath  = /var/log/fail2ban.log
bantime  = 7d
findtime = 1d
maxretry = 5</pre></div>



<p>Save the file and restart Fail2Ban:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">systemctl restart fail2ban</pre></div>



<p>Check the jail status:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">fail2ban-client status recidive</pre></div>



<h2 class="wp-block-heading">How to check who is close to the recidive threshold</h2>



<p>If you want to see IPs that already have several bans and are approaching the recidive threshold:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">grep "Ban " /var/log/fail2ban.log | awk '{print $NF}' | sort | uniq -c | awk '$1 &gt;= 3 {print}' | sort -nr</pre></div>



<h2 class="wp-block-heading">Summary</h2>



<p>Recidive is one of the simplest and most effective ways to limit recurring scanners and bots. Instead of aggressively banning everyone — you block only those who repeatedly come back.</p>



<p>In an environment with multiple domains, Nginx reverse proxy, and WordPress, it’s practically a must-have configuration element: less noise in logs, fewer repeated attacks, and less manual analysis.</p>
<p>Artykuł <a href="https://soban.pl/fail2ban-recidive-nginx-wordpress-setup/">Fail2Ban: How to Detect Repeat Offenders and Ban Them for a Week (Recidive)</a> pochodzi z serwisu <a href="https://soban.pl">soban</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>The most important Linux commands that every user should know</title>
		<link>https://soban.pl/the-most-important-linux-commands-that-every-user-should-know/</link>
		
		<dc:creator><![CDATA[soban]]></dc:creator>
		<pubDate>Thu, 20 Feb 2025 10:56:30 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<guid isPermaLink="false">https://soban.pl/?p=627</guid>

					<description><![CDATA[<p>The Linux system is a powerful tool that offers users tremendous flexibility and control over their working environment. However, to fully harness its potential, it is worth knowing the key commands that are essential for both beginners and advanced users. In this article, we will present and discuss the most important Linux commands that every [&#8230;]</p>
<p>Artykuł <a href="https://soban.pl/the-most-important-linux-commands-that-every-user-should-know/">The most important Linux commands that every user should know</a> pochodzi z serwisu <a href="https://soban.pl">soban</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<figure class="wp-block-image size-large is-resized"><img decoding="async" width="1017" height="1024" src="https://soban.pl/wp-content/uploads/2025/02/image-4-1017x1024.png" alt="" class="wp-image-625" style="width:511px;height:auto" srcset="https://soban.pl/wp-content/uploads/2025/02/image-4-1017x1024.png 1017w, https://soban.pl/wp-content/uploads/2025/02/image-4-298x300.png 298w, https://soban.pl/wp-content/uploads/2025/02/image-4-150x150.png 150w, https://soban.pl/wp-content/uploads/2025/02/image-4-768x774.png 768w, https://soban.pl/wp-content/uploads/2025/02/image-4.png 1105w" sizes="(max-width: 1017px) 100vw, 1017px" /></figure>



<p>The Linux system is a powerful tool that offers users tremendous flexibility and control over their working environment. However, to fully harness its potential, it is worth knowing the key commands that are essential for both beginners and advanced users. In this article, we will present and discuss the most important Linux commands that every user should know.</p>



<h2 class="wp-block-heading">1. Basic Navigation Commands</h2>



<ul class="wp-block-list">
<li><code>pwd</code> &#8211; Displays the current directory path you are in:</li>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">pwd</pre></div>



<li><code>ls</code> &#8211; Lists the contents of a directory. You can use the <code>-l</code> option for a detailed view or <code>-a</code> to show hidden files:</li>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">ls -a</pre></div>



<li><code>cd</code> &#8211; Changes the directory. For example, <code>cd /home/user</code> will move you to the <code>/home/user</code> directory:</li>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">cd ~</pre></div>



<li><code>mkdir</code> &#8211; Creates a new directory:</li>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">mkdir projects</pre></div>



<li><code>rmdir</code> &#8211; Removes an empty directory:</li>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">rmdir old_files</pre></div>
</ul>



<h2 class="wp-block-heading">2. File Management</h2>



<ul class="wp-block-list">
<li><code>cp</code> &#8211; Copies files or directories:</li>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">cp document.txt new_directory/</pre></div>



<li><code>mv</code> &#8211; Moves or renames files/directories:</li>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">mv file.txt /home/user/new_directory/</pre></div>



<li><code>rm</code> &#8211; Removes files or directories. Use the <code>-r</code> option to remove a directory with its contents:</li>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">rm -r old_data</pre></div>



<li><code>touch</code> &#8211; Creates an empty file or updates the modification time of an existing file:</li>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">touch report.txt</pre></div>
</ul>



<h2 class="wp-block-heading">3. Process Management</h2>



<ul class="wp-block-list">
<li><code>ps</code> &#8211; Displays currently running processes. Use the <code>-aux</code> option to see all processes:</li>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">ps -aux</pre></div>



<li><code>top</code> &#8211; Displays a dynamic list of processes in real time:</li>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">top</pre></div>



<li><code>kill</code> &#8211; Stops a process by its ID:</li>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">kill 1234</pre></div>



<li><code>bg</code> and <code>fg</code> &#8211; Manage background and foreground processes:</li>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">fg</pre></div>
</ul>



<h2 class="wp-block-heading">4. User and Permission Management</h2>



<ul class="wp-block-list">
<li><code>sudo</code> &#8211; Allows a command to be executed with administrator privileges:</li>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">sudo apt update</pre></div>



<li><code>chmod</code> &#8211; Changes permissions for files/directories:</li>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">chmod 755 script.sh</pre></div>



<li><code>chown</code> &#8211; Changes the owner of a file/directory:</li>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">chown admin:admin file.txt</pre></div>



<li><code>useradd</code> and <code>userdel</code> &#8211; Adds and removes users:</li>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">useradd janek</pre></div>
</ul>



<h2 class="wp-block-heading">5. Networking and Communication</h2>



<ul class="wp-block-list">
<li><code>ping</code> &#8211; Checks the connection with another host:</li>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">ping 192.168.1.1</pre></div>



<li><code>ifconfig</code> &#8211; Displays information about network interfaces:</li>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">ifconfig</pre></div>



<li><code>ssh</code> &#8211; Connects remotely to another computer:</li>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">ssh user@192.168.1.2</pre></div>



<li><code>scp</code> &#8211; Copies files over SSH:</li>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">scp file.txt user@host:/home/user/</pre></div>
</ul>



<h2 class="wp-block-heading">6. Command Usage Examples</h2>



<p>Below is an example of using several discussed commands:</p>



<ul class="wp-block-list">
<li><code>chmod</code> &#8211; Changes permissions for files/directories:</li>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">chmod 755 script.sh</pre></div>



<li><code>chown</code> &#8211; Changes the owner of a file/directory:</li>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">chown admin:developers logs.txt</pre></div>



<li><code>useradd</code> and <code>userdel</code> &#8211; Adds and removes users:</li>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">useradd janek</pre></div>
</ul>



<h2 class="wp-block-heading">7. Disk and File System Management</h2>



<ul class="wp-block-list">
<li><code>df</code> &#8211; Displays information about disk space availability:</li>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">df -h</pre></div>



<li><code>du</code> &#8211; Shows the size of files and directories:</li>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">du -sh documents</pre></div>



<li><code>mount</code> &#8211; Mounts a file system:</li>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">mount /dev/sdb1 /mnt/external</pre></div>



<li><code>umount</code> &#8211; Unmounts a file system:</li>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">umount /mnt/external</pre></div>
</ul>



<h2 class="wp-block-heading">8. Searching for Files</h2>



<ul class="wp-block-list">
<li><code>find</code> &#8211; Searches for files in the system:</li>



<li><code>locate</code> &#8211; Quickly searches for files in the system:</li>



<li><code>grep</code> &#8211; Searches for patterns in files:</li>



<li><code>which</code> &#8211; Finds the full path to an executable file:</li>
</ul>



<h2 class="wp-block-heading">9. Communicating with the System</h2>



<ul class="wp-block-list">
<li><code>echo</code> &#8211; Displays text on the screen:</li>



<li><code>cat</code> &#8211; Displays the contents of a file:</li>



<li><code>more</code> &#8211; Displays the contents of a file page by page:</li>



<li><code>less</code> &#8211; Similar to more, but offers more navigation options:</li>



<li><code>man</code> &#8211; Displays the user manual for a command:</li>
</ul>



<h2 class="wp-block-heading">10. Working with Archives</h2>



<ul class="wp-block-list">
<li><code>tar</code> &#8211; Creates or extracts archives:</li>



<li><code>zip</code> &#8211; Creates a ZIP archive:</li>



<li><code>unzip</code> &#8211; Extracts ZIP files:</li>



<li><code>tar -xvzf</code> &#8211; Extracts a TAR.GZ archive:</li>



<li><code>gzip</code> &#8211; Compresses files in .gz format:</li>



<li><code>gunzip</code> &#8211; Extracts .gz files:</li>
</ul>



<h2 class="wp-block-heading">11. System Monitoring</h2>



<ul class="wp-block-list">
<li><code>uptime</code> &#8211; Displays the system uptime and load:</li>



<li><code>dmesg</code> &#8211; Displays system messages related to boot and hardware:</li>



<li><code>iostat</code> &#8211; Shows input/output system statistics:</li>



<li><code>free</code> &#8211; Displays information about RAM:</li>



<li><code>netstat</code> &#8211; Displays information about network connections:</li>



<li><code>ss</code> &#8211; A modern version of netstat, used for monitoring network connections:</li>
</ul>



<h2 class="wp-block-heading">12. Working with System Logs</h2>



<ul class="wp-block-list">
<li><code>journalctl</code> &#8211; Reviews system logs:</li>



<li><code>tail</code> &#8211; Displays the last lines of a file:</li>



<li><code>logrotate</code> &#8211; Automatically manages logs:</li>
</ul>



<h2 class="wp-block-heading">13. Advanced File Operations</h2>



<ul class="wp-block-list">
<li><code>ln</code> &#8211; Creates a link to a file:</li>



<li><code>xargs</code> &#8211; Passes arguments from input to other commands:</li>



<li><code>chmod</code> &#8211; Changes permissions for files/directories:</li>



<li><code>chattr</code> &#8211; Changes file attributes:</li>
</ul>


<p>Linux offers a wide array of commands that allow for complete control over the computer. Key commands such as <code>ls</code>, <code>cd</code>, <code>cp</code>, and <code>rm</code> are used daily to navigate through the file system, manage files, and directories. To effectively master these commands, it&#8217;s best to start with those that are most useful in everyday work. For instance, commands for navigating directories and managing files are fundamental and require practice to become intuitive. Other commands, such as <code>ps</code> for monitoring processes, <code>ping</code> for testing network connections, or <code>chmod</code> for changing permissions, are also worth knowing to fully leverage the power of the Linux system.</p>
<p><!-- /wp:post-content --></p>
<p><!-- wp:paragraph --></p>
<p>To learn effectively, it&#8217;s advisable to start by experimenting with commands in practice. Creating files, directories, copying, and deleting data allows for familiarity with their operation. Over time, it&#8217;s worthwhile to start combining different commands to solve more advanced problems, such as monitoring processes, managing users, or working with system logs. One can also use documentation, such as <code>man</code> or websites, to delve into the details of each command and its options.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Remember, regular use of the terminal allows for learning habits that make handling the Linux system more natural. Frequent use of commands, solving problems, and experimenting with new commands is the best way to master the system and fully utilize it.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Linux is indeed a powerful tool that provides great control over the system&#8230; but remember, don&#8217;t experiment on production! After all, experimenting on a production server is a bit like playing Russian roulette — only with bigger consequences. If you want to feel like a true Linux wizard, always test your commands in a development environment. Only then will you be able to learn from mistakes instead of searching for the cause of several gigabytes of data disappearance. And if you don&#8217;t know what you&#8217;re doing, simply summon your trusty weapon: <code>man</code>!</p>
<p><!-- /wp:paragraph --></p>
<p>Artykuł <a href="https://soban.pl/the-most-important-linux-commands-that-every-user-should-know/">The most important Linux commands that every user should know</a> pochodzi z serwisu <a href="https://soban.pl">soban</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Automatic deletion of files on QNAP drive via SSHFS</title>
		<link>https://soban.pl/automatic-deletion-of-files-on-qnap-drive-via-sshfs/</link>
		
		<dc:creator><![CDATA[soban]]></dc:creator>
		<pubDate>Fri, 07 Feb 2025 15:05:17 +0000</pubDate>
				<category><![CDATA[Bash]]></category>
		<category><![CDATA[Linux]]></category>
		<guid isPermaLink="false">https://soban.pl/?p=584</guid>

					<description><![CDATA[<p>Automation of Disk Space Management in a Linux Environment In today&#8217;s digital world, where data is being accumulated in ever-increasing amounts, managing disk space has become a key aspect of maintaining operational efficiency in systems. In this article, I will present a script that automates the process of managing space on a remote disk mounted [&#8230;]</p>
<p>Artykuł <a href="https://soban.pl/automatic-deletion-of-files-on-qnap-drive-via-sshfs/">Automatic deletion of files on QNAP drive via SSHFS</a> pochodzi z serwisu <a href="https://soban.pl">soban</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<figure class="wp-block-image size-full"><img decoding="async" width="501" height="497" src="https://soban.pl/wp-content/uploads/2025/02/image.png" alt="" class="wp-image-574" srcset="https://soban.pl/wp-content/uploads/2025/02/image.png 501w, https://soban.pl/wp-content/uploads/2025/02/image-300x298.png 300w, https://soban.pl/wp-content/uploads/2025/02/image-150x150.png 150w" sizes="(max-width: 501px) 100vw, 501px" /></figure>



<p><br><strong>Automation of Disk Space Management in a Linux Environment</strong></p>



<p>In today&#8217;s digital world, where data is being accumulated in ever-increasing amounts, managing disk space has become a key aspect of maintaining operational efficiency in systems. In this article, I will present a script that automates the process of managing space on a remote disk mounted via SSHFS, particularly useful for system administrators who regularly deal with filling storage media.</p>



<h3 class="wp-block-heading">Prerequisites</h3>



<p>Before starting, ensure that SSHFS and all necessary packages enabling its proper operation are installed on your system. SSHFS allows remote file systems to be mounted via SSH, which is crucial for our script&#8217;s operation. To install SSHFS and the necessary tools, including a package that enables password forwarding (sshpass), use the following command:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">apt-get update
apt-get install sshfs fuse sshpass -y</pre></div>



<h3 class="wp-block-heading">Bash Script for Disk Space Management</h3>



<p>Our Bash script focuses on monitoring and maintaining a defined percentage of free disk space on a remote disk mounted via SSHFS. Here are the script&#8217;s main functions:</p>



<p><strong>Goal Definition:</strong></p>



<p>TARGET_USAGE=70 &#8211; the percentage of disk space we want to maintain as occupied. The script will work to keep at least 30% of the disk space free.</p>



<p><strong>Mount Point and Paths:</strong></p>



<p>MOUNT_POINT=&#8221;/mnt/qnapskorupki&#8221; &#8211; the local directory where the remote disk is mounted. TARGET_DIRS=&#8221;$MOUNT_POINT/up*.soban.pl&#8221; &#8211; the directories where the script will look for files to delete if needed.</p>



<p><strong>Function check_qnap:</strong> This function checks whether the disk is mounted and whether the mount directory is not empty. If there are issues, the script attempts to unmount and remount the disk using sshfs with a password forwarded through sshpass.</p>



<p><strong>File Deletion:</strong> The script monitors disk usage and, if TARGET_USAGE is exceeded, it finds and deletes the oldest files in specified directories until the target level of free space is achieved.</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">#!/bin/bash

TARGET_USAGE=70
MOUNT_POINT="/mnt/qnapskorupki"
TARGET_DIRS="$MOUNT_POINT/up*.soban.pl"

# Function to check and mount SSHFS
function check_qnap {
    local remote_path="/share/MD0_DATA/backup_proxmox/"
    local user_remote="remote_user"
    local remote_host="192.168.1.XX"
    local port=22
    local password='XXXXXXXXXXXXXXXXXXXXXXX'

    # Check if the mounting directory exists and is empty
    if [ ! -d "$MOUNT_POINT" ] || [ -z "$(ls -A $MOUNT_POINT)" ]; then
        echo "Problem: The directory $MOUNT_POINT is missing or empty. Attempting to remount..."

        # Unmount if anything is currently mounted
        if mountpoint -q $MOUNT_POINT; then
            echo "Unmounting $MOUNT_POINT..."
            fusermount -u $MOUNT_POINT
            sleep 5
        fi

        # Remount
        echo "Mounting SSHFS: $user_remote@$remote_host:$remote_path to $MOUNT_POINT..."
        echo $password | sshfs $user_remote@$remote_host:$remote_path $MOUNT_POINT -o password_stdin

        # Check if the mounting was successful
        if mountpoint -q $MOUNT_POINT; then
            echo "QNAP successfully mounted."
        else
            echo "Error: Failed to mount $remote_host:$remote_path to $MOUNT_POINT."
            exit 1
        fi
    fi
}

# Check and mount the disk
check_qnap

# Begin deleting files
current_usage=$(df --output=pcent "$MOUNT_POINT" | tail -n 1 | tr -d '%')
echo "Current usage: $current_usage%"
target_free_space=$((100 - $TARGET_USAGE))

# Continue deleting files until the required free space is achieved
while [[ $current_usage -gt $TARGET_USAGE ]]; do
    # Find the oldest file in the target directories
    oldest_file=$(find $TARGET_DIRS -type f -printf '%T+ %p\n' | sort | head -n 1 | cut -d' ' -f2)

    if [ -z "$oldest_file" ]; then
        echo "No files to delete."
        break
    fi

    # Delete the oldest file
    echo "Deleting file $oldest_file..."
    rm -f "$oldest_file"

    # Check usage again
    current_usage=$(df --output=pcent "$MOUNT_POINT" | tail -n 1 | tr -d '%')
    echo "New usage after deletion: $current_usage%"
done

echo "Target disk usage achieved."</pre></div>



<h3 class="wp-block-heading">Example Script Execution:</h3>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="795" height="164" src="https://soban.pl/wp-content/uploads/2025/02/Zrzut-ekranu-2025-02-07-153719-4.png" alt="script starts working and gradually deletes files" class="wp-image-579" srcset="https://soban.pl/wp-content/uploads/2025/02/Zrzut-ekranu-2025-02-07-153719-4.png 795w, https://soban.pl/wp-content/uploads/2025/02/Zrzut-ekranu-2025-02-07-153719-4-300x62.png 300w, https://soban.pl/wp-content/uploads/2025/02/Zrzut-ekranu-2025-02-07-153719-4-768x158.png 768w" sizes="auto, (max-width: 795px) 100vw, 795px" /></figure>



<p>The script will run until it reaches 70% usage as planned:</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="778" height="232" src="https://soban.pl/wp-content/uploads/2025/02/2.jpg" alt="Script runs until reaching 70%" class="wp-image-580" srcset="https://soban.pl/wp-content/uploads/2025/02/2.jpg 778w, https://soban.pl/wp-content/uploads/2025/02/2-300x89.jpg 300w, https://soban.pl/wp-content/uploads/2025/02/2-768x229.jpg 768w" sizes="auto, (max-width: 778px) 100vw, 778px" /></figure>



<h3 class="wp-block-heading" id="block-9d63e003-5e0a-4d60-ae2f-63ff55112faa">Downloading the script and adding it to crontab</h3>



<p id="block-5f75769c-f8fb-4978-ac2d-e8e7868fa484">Of course, the script should be adjusted to meet your specific needs. However, if you want to download it and add it to crontab, follow these steps:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">wget soban.pl/bash/remove_old_files.sh
chmod +x remove_old_files.sh</pre></div>



<p id="block-5f75769c-f8fb-4978-ac2d-e8e7868fa484">If you want to automate the file removal process, for example, at the end of the day, add the following entry to crontab:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">crontab -e</pre></div>



<p id="block-5f75769c-f8fb-4978-ac2d-e8e7868fa484">In this case, the script will run every day at 11:55 PM:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">45 23 * * * /root/scripts/remove_old_files.sh &gt; /dev/null 2&gt;&amp;1</pre></div>



<p id="block-5f75769c-f8fb-4978-ac2d-e8e7868fa484">Make sure to use the correct path to the script.</p>



<h3 class="wp-block-heading">Security and Optimization</h3>



<p>The script uses a password directly in the command line, which can pose a security risk. In practical applications, it is recommended to use more advanced authentication methods, such as SSH keys, which are more secure and do not require a plaintext password in the script. However, in the case of QNAP, we used a password when writing this script.</p>



<h3 class="wp-block-heading">Conclusion</h3>



<p>The presented script is an example of how daily administrative tasks, such as disk space management, can be automated, thus increasing efficiency and reliability. Its implementation in real IT environments can significantly streamline data management processes, especially in situations where quick response to changes in disk usage is critical.</p>
<p>Artykuł <a href="https://soban.pl/automatic-deletion-of-files-on-qnap-drive-via-sshfs/">Automatic deletion of files on QNAP drive via SSHFS</a> pochodzi z serwisu <a href="https://soban.pl">soban</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>How to automatically turn off your laptop when battery status is displayed in Linux</title>
		<link>https://soban.pl/how-to-automatically-turn-off-your-laptop-when-battery-status-is-displayed-in-linux/</link>
		
		<dc:creator><![CDATA[soban]]></dc:creator>
		<pubDate>Fri, 24 Jan 2025 10:30:58 +0000</pubDate>
				<category><![CDATA[Battery]]></category>
		<category><![CDATA[Linux]]></category>
		<guid isPermaLink="false">https://soban.pl/?p=546</guid>

					<description><![CDATA[<p>Automatically Shutting Down Your Laptop at Low Battery Levels Maintaining long battery life and protecting data are crucial for laptop users. In this article, we&#8217;ll show you how to create a simple Bash script that automatically shuts down your laptop when the battery level falls below 20%. Additionally, you&#8217;ll learn how to set up a [&#8230;]</p>
<p>Artykuł <a href="https://soban.pl/how-to-automatically-turn-off-your-laptop-when-battery-status-is-displayed-in-linux/">How to automatically turn off your laptop when battery status is displayed in Linux</a> pochodzi z serwisu <a href="https://soban.pl">soban</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<figure class="wp-block-image size-large is-resized"><img loading="lazy" decoding="async" width="1019" height="1024" src="https://soban.pl/wp-content/uploads/2025/01/image-1-1019x1024.png" alt="" class="wp-image-547" style="width:619px;height:auto" srcset="https://soban.pl/wp-content/uploads/2025/01/image-1-1019x1024.png 1019w, https://soban.pl/wp-content/uploads/2025/01/image-1-298x300.png 298w, https://soban.pl/wp-content/uploads/2025/01/image-1-150x150.png 150w, https://soban.pl/wp-content/uploads/2025/01/image-1-768x772.png 768w, https://soban.pl/wp-content/uploads/2025/01/image-1.png 1122w" sizes="auto, (max-width: 1019px) 100vw, 1019px" /></figure>



<p><br>Automatically Shutting Down Your Laptop at Low Battery Levels</p>



<p>Maintaining long battery life and protecting data are crucial for laptop users. In this article, we&#8217;ll show you how to create a simple Bash script that automatically shuts down your laptop when the battery level falls below 20%. Additionally, you&#8217;ll learn how to set up a crontab to run the script every 10 minutes, ensuring continuous monitoring.</p>



<h3 class="wp-block-heading">Creating a Bash Script</h3>



<p>The Bash script we have prepared will check the current battery level and compare it to a set minimum threshold. If the battery level drops below this threshold, the script initiates a system shutdown, helping to protect your data and hardware.</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">#!/bin/bash

# Define the minimum battery level before shutdown
MIN_BATTERY_LEVEL=20

# Get the current battery level
current_level=$(cat /sys/class/power_supply/BAT0/capacity)

# Check if the current battery level is less than or equal to the minimum level
if [[ "$current_level" -le "$MIN_BATTERY_LEVEL" ]]; then
  echo "Battery level is $current_level%, which is below the threshold of $MIN_BATTERY_LEVEL%. Shutting down..."
  # Shutdown command
  /sbin/shutdown -h now
else
  echo "Battery level is $current_level%, no need to shut down."
fi</pre></div>



<p>Also you can download script:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">wget https://soban.pl/bash/check_battery.sh</pre></div>



<p>Don&#8217;t forget to grant permissions to run it:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">chmod +x check_battery.sh</pre></div>



<h3 class="wp-block-heading">Crontab Configuration</h3>



<p>Crontab is a tool that allows you to schedule tasks in the Linux system. With it, we can set up regular battery checks.</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">crontab -e

# Add the following line to crontab to run the script every 10 minutes
*/10 * * * * /root/check_battery.sh &gt; /dev/null 2&gt;&amp;1</pre></div>



<h3 class="wp-block-heading">Summary</h3>



<p>With this setup, you can rest assured about the condition of your laptop even during intensive use. Automatic shutdown at low battery levels not only protects the equipment but also helps maintain a longer battery life.</p>
<p>Artykuł <a href="https://soban.pl/how-to-automatically-turn-off-your-laptop-when-battery-status-is-displayed-in-linux/">How to automatically turn off your laptop when battery status is displayed in Linux</a> pochodzi z serwisu <a href="https://soban.pl">soban</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Troubleshooting Proxmox clusters and restoring the LXC container</title>
		<link>https://soban.pl/troubleshooting-proxmox-clusters-and-restoring-the-lxc-container/</link>
		
		<dc:creator><![CDATA[soban]]></dc:creator>
		<pubDate>Wed, 13 Nov 2024 10:57:41 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Proxmox]]></category>
		<guid isPermaLink="false">https://soban.pl/?p=519</guid>

					<description><![CDATA[<p>Managing Proxmox clusters can sometimes present technical difficulties, such as inconsistencies in cluster configuration or issues with restoring LXC containers. Finding and resolving these issues is crucial for maintaining the stability and performance of the virtualization environment. In this article, I present a detailed guide on how to diagnose and resolve an issue with an [&#8230;]</p>
<p>Artykuł <a href="https://soban.pl/troubleshooting-proxmox-clusters-and-restoring-the-lxc-container/">Troubleshooting Proxmox clusters and restoring the LXC container</a> pochodzi z serwisu <a href="https://soban.pl">soban</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<figure class="wp-block-image size-full is-resized"><img loading="lazy" decoding="async" width="774" height="782" src="https://soban.pl/wp-content/uploads/2024/11/image.png" alt="" class="wp-image-520" style="width:485px;height:auto" srcset="https://soban.pl/wp-content/uploads/2024/11/image.png 774w, https://soban.pl/wp-content/uploads/2024/11/image-297x300.png 297w, https://soban.pl/wp-content/uploads/2024/11/image-768x776.png 768w" sizes="auto, (max-width: 774px) 100vw, 774px" /></figure>



<p>Managing Proxmox clusters can sometimes present technical difficulties, such as inconsistencies in cluster configuration or issues with restoring LXC containers. Finding and resolving these issues is crucial for maintaining the stability and performance of the virtualization environment. In this article, I present a detailed guide on how to diagnose and resolve an issue with an unreachable node and how to successfully restore an LXC container.</p>



<p>Before you begin any actions, make sure you have a current backup of the system.</p>



<h3 class="wp-block-heading">Diagnosing the State of the Proxmox Cluster<br></h3>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">pvecm delnode up-page-02
Node/IP: up-page-02 is not a known host of the cluster.</pre></div>



<p>and:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">pct restore 107 vzdump-lxc-107-2024_11_12-03_00_01.tar.zst --storage local
CT 107 already exists on node 'up-page-02'</pre></div>



<p>To understand the state of the cluster, execute the following command on the <code>node-up-page-04</code> node:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">pvecm nodes</pre></div>



<p>Expected output:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">Membership information
----------------------
    Nodeid      Votes Name
         1          1 node-up-page-01
         2          1 node-up-page-04 (local)</pre></div>



<p>Then check the detailed cluster information with the following command:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">pvecm status</pre></div>



<p>Expected output:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">Cluster information
-------------------
Name:             soban-proxmox
Config Version:   4
Transport:        knet
Secure auth:      on

Quorum information
------------------
Date:             Wed Nov 13 10:40:12 2024
Quorum provider:  corosync_votequorum
Nodes:            2
Node ID:          0x00000002
Ring ID:          1.e6
Quorate:          Yes

Votequorum information
----------------------
Expected votes:   2
Highest expected: 2
Total votes:      2
Quorum:           2
Flags:            Quorate

Membership information
----------------------
    Nodeid      Votes Name
0x00000001          1 &lt;masked IP&gt;
0x00000002          1 &lt;masked IP&gt; (local)</pre></div>



<h3 class="wp-block-heading">Removing the Container Configuration File and Cleaning Data</h3>



<p>I discovered that the configuration file for container 107 still exists on the cluster&#8217;s file system at the path:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">ls -ltr /etc/pve/nodes/node-up-page-02/lxc/107.conf</pre></div>



<p>Output:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">-rw-r----- 1 root www-data 235 Nov 12 21:35 /etc/pve/nodes/node-up-page-02/lxc/107.conf</pre></div>



<p>To remove this file and any remaining data associated with the detached node, execute:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">rm -rf /etc/pve/nodes/node-up-page-02/</pre></div>



<h3 class="wp-block-heading">Restoring the Container</h3>



<p>After removing the configuration file, I restored the LXC container on the <code>node-up-page-04</code> node using the command:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">pct restore 107 /root/vzdump-lxc-107-2024_11_12-03_00_01.tar.zst --storage local</pre></div>



<p>Output:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">recovering backed-up configuration from '/root/vzdump-lxc-107-2024_11_12-03_00_01.tar.zst'
Formatting '/var/lib/vz/images/107/vm-107-disk-0.raw', fmt=raw size=59055800320 preallocation=off
Creating filesystem with 14417920 4k blocks and 3604480 inodes
Filesystem UUID: 8b707e55-5e14-4b20-8585-6cb09e0fa520
Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 4096000, 7962624, 11239424
restoring '/root/vzdump-lxc-107-2024_11_12-03_00_01.tar.zst' now..
extracting archive '/root/vzdump-lxc-107-2024_11_12-03_00_01.tar.zst'</pre></div>



<p>The restoration process was successful, and the container was ready for use. This case illustrates the importance of thorough diagnostics and configuration file management in Proxmox when working with clusters. Regular reviews of configurations are advisable to avoid inconsistencies and operational issues in the future.</p>
<p>Artykuł <a href="https://soban.pl/troubleshooting-proxmox-clusters-and-restoring-the-lxc-container/">Troubleshooting Proxmox clusters and restoring the LXC container</a> pochodzi z serwisu <a href="https://soban.pl">soban</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>How to prevent hibernation and sleep on debian and proxmox laptops when the lid is closed</title>
		<link>https://soban.pl/disable-debian-laptop-sleep-hibernation-lid-close/</link>
		
		<dc:creator><![CDATA[soban]]></dc:creator>
		<pubDate>Fri, 19 Apr 2024 11:59:12 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<guid isPermaLink="false">https://soban.pl/?p=478</guid>

					<description><![CDATA[<p>Virtualization servers based on Debian family systems, such as Proxmox, are often used in test environments where continuous availability is crucial. Sometimes these servers are installed on laptops, which serve as low-budget or portable solutions. However, the standard power management settings in laptops can lead to undesirable behaviors, such as sleeping or hibernating when the [&#8230;]</p>
<p>Artykuł <a href="https://soban.pl/disable-debian-laptop-sleep-hibernation-lid-close/">How to prevent hibernation and sleep on debian and proxmox laptops when the lid is closed</a> pochodzi z serwisu <a href="https://soban.pl">soban</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<figure class="wp-block-image size-full is-resized"><img loading="lazy" decoding="async" width="1024" height="1024" src="https://soban.pl/wp-content/uploads/2024/04/image-1.png" alt="" class="wp-image-476" style="width:463px;height:auto" srcset="https://soban.pl/wp-content/uploads/2024/04/image-1.png 1024w, https://soban.pl/wp-content/uploads/2024/04/image-1-300x300.png 300w, https://soban.pl/wp-content/uploads/2024/04/image-1-150x150.png 150w, https://soban.pl/wp-content/uploads/2024/04/image-1-768x768.png 768w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>Virtualization servers based on Debian family systems, such as Proxmox, are often used in test environments where continuous availability is crucial. Sometimes these servers are installed on laptops, which serve as low-budget or portable solutions. However, the standard power management settings in laptops can lead to undesirable behaviors, such as sleeping or hibernating when the lid is closed. Below, I describe how to change these settings in an operating system based on Debian to ensure uninterrupted server operation.</p>



<h3 class="wp-block-heading">Step 1: Accessing the Configuration File</h3>



<p>Open the terminal and enter the following command to edit the <code>/etc/systemd/logind.conf</code> file using a text editor (e.g., nano):</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">nano /etc/systemd/logind.conf</pre></div>



<h3 class="wp-block-heading">Step 2: Modifying logind Settings</h3>



<p>Find the line containing <code>HandleLidSwitch</code> and change its value to <code>ignore</code>. If the line is commented out (preceded by a <code>#</code> symbol), remove the <code>#</code>. You can also add this line to the end of the file if it does not exist.</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">HandleLidSwitch=ignore</pre></div>



<h3 class="wp-block-heading">Step 3: Applying and Restarting the Service</h3>



<p>After making the changes and saving the file, you need to restart the <code>systemd-logind</code> service for the changes to take effect. Use the following command in the terminal:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">systemctl restart systemd-logind</pre></div>



<p>With these changes, closing the laptop lid will no longer initiate hibernation or sleep, which is especially important when using Debian-based servers, including Proxmox, as server solutions.</p>
<p>Artykuł <a href="https://soban.pl/disable-debian-laptop-sleep-hibernation-lid-close/">How to prevent hibernation and sleep on debian and proxmox laptops when the lid is closed</a> pochodzi z serwisu <a href="https://soban.pl">soban</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Extending SWAP space on Proxmox using lvreduce</title>
		<link>https://soban.pl/extending-swap-space-on-proxmox-using-lvreduce/</link>
		
		<dc:creator><![CDATA[soban]]></dc:creator>
		<pubDate>Thu, 18 Apr 2024 10:55:30 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Proxmox]]></category>
		<category><![CDATA[SWAP]]></category>
		<guid isPermaLink="false">https://soban.pl/?p=470</guid>

					<description><![CDATA[<p>Introduction Managing SWAP memory is a key element in administering Linux operating systems, especially in virtualization environments like Proxmox. SWAP acts as &#8220;virtual memory&#8221; that can be used when the system&#8217;s physical RAM is full. In this article, we will show how to increase SWAP space on a Proxmox server, using the lvresize tool to [&#8230;]</p>
<p>Artykuł <a href="https://soban.pl/extending-swap-space-on-proxmox-using-lvreduce/">Extending SWAP space on Proxmox using lvreduce</a> pochodzi z serwisu <a href="https://soban.pl">soban</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<figure class="wp-block-image size-full is-resized"><img loading="lazy" decoding="async" width="844" height="846" src="https://soban.pl/wp-content/uploads/2024/04/swap.png" alt="" class="wp-image-467" style="width:427px;height:auto" srcset="https://soban.pl/wp-content/uploads/2024/04/swap.png 844w, https://soban.pl/wp-content/uploads/2024/04/swap-300x300.png 300w, https://soban.pl/wp-content/uploads/2024/04/swap-150x150.png 150w, https://soban.pl/wp-content/uploads/2024/04/swap-768x770.png 768w" sizes="auto, (max-width: 844px) 100vw, 844px" /></figure>



<p><strong>Introduction</strong></p>



<p>Managing SWAP memory is a key element in administering Linux operating systems, especially in virtualization environments like Proxmox. SWAP acts as &#8220;virtual memory&#8221; that can be used when the system&#8217;s physical RAM is full. In this article, we will show how to increase SWAP space on a Proxmox server, using the lvresize tool to free up disk space that can then be allocated to SWAP.</p>



<h3 class="wp-block-heading">Problem Overview</h3>



<p>A user wants to increase SWAP space from 8 GB to 16 GB, but encounters the problem of lacking available space in the LVM volume group, which is required to increase SWAP.</p>



<h3 class="wp-block-heading">Step 1: Checking Available Space</h3>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">vgs</pre></div>



<p>The command <code>vgs</code> displays the volume groups along with their sizes and available space.</p>



<h3 class="wp-block-heading">Step 2: Reducing the Volume</h3>



<p>Suppose there is a <code>root</code> volume of 457.26 GB, which can be reduced to free up an additional 8 GB for SWAP. Before reducing the volume, it is necessary to reduce the file system on this volume.</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">resize2fs /dev/pve/root 449.26G</pre></div>



<p>However, in the case of the XFS file system, reduction must occur offline or from a live CD.</p>



<h3 class="wp-block-heading">Step 3: Using lvreduce</h3>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">lvreduce -L -8G /dev/pve/root</pre></div>



<p>This command reduces the <code>root</code> volume by 8 GB, which is confirmed by a message about the volume size change.</p>



<h3 class="wp-block-heading">Step 4: Deactivating SWAP</h3>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">swapoff -a</pre></div>



<p>Before starting changes in SWAP size, SWAP must first be turned off using the above command.</p>



<h3 class="wp-block-heading">Step 5: Expanding SWAP</h3>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">lvresize -L +8G /dev/pve/swap
mkswap /dev/pve/swap
swapon /dev/pve/swap</pre></div>



<p>The above commands first increase the SWAP space, then format it and reactivate it.</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">swapon --show</pre></div>



<p>Finally, we verify the active SWAP areas using the above command to ensure everything is configured correctly.</p>



<p>This process shows how you can flexibly manage disk space on Proxmox servers, adjusting the size of SWAP depending on needs. Using <code>lvreduce</code> requires caution, as any operation on partitions and volumes carries the risk of data loss, therefore it is always recommended to make backups before proceeding with changes.</p>
<p>Artykuł <a href="https://soban.pl/extending-swap-space-on-proxmox-using-lvreduce/">Extending SWAP space on Proxmox using lvreduce</a> pochodzi z serwisu <a href="https://soban.pl">soban</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Upgrading Apache Cassandra from Version 3.1.15 and Higher to 4.1.x on Ubuntu 20.04.5 LTS: A Comprehensive Guide</title>
		<link>https://soban.pl/upgrading-apache-cassandra-from-version-3-1-15-and-higher-to-4-1-x-on-ubuntu-20-04-5-lts-a-comprehensive-guide/</link>
		
		<dc:creator><![CDATA[soban]]></dc:creator>
		<pubDate>Mon, 11 Mar 2024 16:39:50 +0000</pubDate>
				<category><![CDATA[Bash]]></category>
		<category><![CDATA[Cassandra]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Nodetool]]></category>
		<category><![CDATA[Patching]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<guid isPermaLink="false">https://soban.pl/?p=410</guid>

					<description><![CDATA[<p>Upgrading Apache Cassandra to a newer version is a significant task that database administrators undertake to ensure their systems benefit from new features, enhanced security measures, and improved performance. This guide provides a detailed walkthrough for upgrading Apache Cassandra from version 3.1.15 and higher to the latest 4.1.x version, specifically on Ubuntu 20.04.5 LTS, with [&#8230;]</p>
<p>Artykuł <a href="https://soban.pl/upgrading-apache-cassandra-from-version-3-1-15-and-higher-to-4-1-x-on-ubuntu-20-04-5-lts-a-comprehensive-guide/">Upgrading Apache Cassandra from Version 3.1.15 and Higher to 4.1.x on Ubuntu 20.04.5 LTS: A Comprehensive Guide</a> pochodzi z serwisu <a href="https://soban.pl">soban</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1024" height="1024" src="https://soban.pl/wp-content/uploads/2024/03/image.png" alt="" class="wp-image-413" srcset="https://soban.pl/wp-content/uploads/2024/03/image.png 1024w, https://soban.pl/wp-content/uploads/2024/03/image-300x300.png 300w, https://soban.pl/wp-content/uploads/2024/03/image-150x150.png 150w, https://soban.pl/wp-content/uploads/2024/03/image-768x768.png 768w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>Upgrading Apache Cassandra to a newer version is a significant task that database administrators undertake to ensure their systems benefit from new features, enhanced security measures, and improved performance. This guide provides a detailed walkthrough for upgrading Apache Cassandra from version 3.1.15 and higher to the latest 4.1.x version, specifically on Ubuntu 20.04.5 LTS, with an emphasis on pre-upgrade cleaning operations to manage disk space effectively.</p>



<h3 class="wp-block-heading">Pre-upgrade Preparation</h3>



<p><strong>Backup Configuration Directory:</strong></p>



<p>Before initiating the upgrade, it&#8217;s crucial to back up the Cassandra configuration directory. This precaution allows for a swift restoration of the configuration should any issues arise during the upgrade process. Utilize the following command to create a backup, incorporating the current date into the folder name for easy identification:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># cp -r /etc/cassandra/ /root/cassandra-conf-bkp-$(date +%Y%m%d)</pre></div>



<p><strong>Pre-Cleanup Operations</strong></p>



<p>Preparation is key to a smooth upgrade. Begin with maintenance commands to guarantee data integrity and optimize space usage, especially important for systems with limited disk space.</p>



<p><strong>Scrub Data:</strong></p>



<p>Execute <code>nodetool scrub</code> to clean and reorganize data on disk. Given that this operation may be time-consuming, particularly for databases with large amounts of data or limited disk space, it&#8217;s a critical step for a healthy upgrade process.</p>



<p><strong>Clear Snapshots:</strong></p>



<p>To further manage disk space, use <code>nodetool clearsnapshot</code> to remove existing snapshots, freeing up space for the upgrade process. To delete all snapshots on the node, simply use this method if you&#8217;re running out of space:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># nodetool clearsnapshot --all</pre></div>



<p><strong>Cleanup Data:</strong></p>



<p>Perform a <code>nodetool cleanup</code> to purge unnecessary data. In scenarios where disk space is a premium, it&#8217;s advisable to execute a scrub operation without generating a snapshot to conserve space:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># nodetool scrub --no-snapshot</pre></div>



<h3 class="wp-block-heading">Draining and Stopping Cassandra</h3>



<p><strong>Drain the Node:</strong></p>



<p>Prior to halting the Cassandra service, ensure all data in memory is flushed to disk with <code>nodetool drain</code>.</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># nodetool drain</pre></div>



<p><strong>Stop the Cassandra Service:</strong></p>



<p>Cease the running Cassandra services to proceed with the upgrade safely:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># systemctl stop cassandra.service</pre></div>



<h3 class="wp-block-heading">Upgrading Cassandra</h3>



<p><strong>Update Source List:</strong></p>



<p>Edit the repository sources to point to the new version of Cassandra by adjusting the <code>cassandra.sources.list</code> file:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># echo "deb https://debian.cassandra.apache.org 41x main" &gt; /etc/apt/sources.list.d/cassandra.sources.list</pre></div>



<p><strong>Upgrade Packages:</strong></p>



<p>With the repository sources updated, refresh the package list and upgrade the packages. When executing the <code>apt upgrade</code> command, you can keep pressing Enter as the default option is &#8216;N&#8217; (No):</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># apt update &amp;&amp; apt upgrade</pre></div>



<p><strong>Modify Configuration:</strong></p>



<p>Adjust the Cassandra configuration for version 4.1.x by commenting out or deleting deprecated options:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># for var in thrift_prepared_statements_cache_size_mb start_rpc rpc_port rpc_server_type thrift_framed_transport_size_in_mb request_scheduler; do sed -i "/$var:/s/^/#/" /etc/cassandra/cassandra.yaml; done</pre></div>



<p><strong>Update JAMM Library:</strong></p>



<p>Ensure the Java Agent Memory Manager (JAMM) library is updated to enhance performance:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># sed -i 's|jamm-0.3.0.jar|jamm-0.3.2.jar|g' /etc/cassandra/cassandra-env.sh</pre></div>



<p><strong>Backup and update the JVM options file</strong>:</p>



<p>It&#8217;s a good practice to back up configuration files before making changes. This step renames the existing <code>jvm-server.options</code> file to <code>jvm-server.options.orig</code> as a backup. Then, it copies the <code>jvm.options</code> file to <code>jvm-server.options</code> to apply the standard JVM options for Cassandra servers.</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># cd /etc/cassandra/
# mv jvm-server.options jvm-server.options.orig &amp;&amp; cp -p jvm.options jvm-server.options</pre></div>



<h3 class="wp-block-heading">Optimization and Verification</h3>



<p><strong>Optimize Memory Usage:</strong></p>



<p>Post-upgrade, it&#8217;s beneficial to evaluate and optimize memory usage and swap space to ensure efficient Cassandra operation:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># swapoff -a &amp;&amp; swapon -a</pre></div>



<p><strong>Restart the Cassandra Service:</strong></p>



<p>Apply the new version by restarting the Cassandra service:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># systemctl start cassandra.service</pre></div>



<p><strong>Verify Upgrade:</strong></p>



<p>Confirm the success of the upgrade by inspecting the cluster&#8217;s topology and state, ensuring all nodes are functional:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># nodetool describecluster
# nodetool status</pre></div>



<p>By adhering to this comprehensive guide, database administrators can effectively upgrade Apache Cassandra to version 4.1.x, capitalizing on the latest advancements and optimizations the platform has to offer, while ensuring data integrity and system performance through careful pre-upgrade preparations.</p>



<p><strong>Optimization and Verification</strong></p>



<p>After successfully upgrading Apache Cassandra to version 4.1.x and ensuring the cluster is fully operational, it&#8217;s crucial to conduct post-upgrade maintenance to optimize the performance and security of your database system. This section outlines essential steps and considerations to maintain a healthy and efficient Cassandra environment.<br><br><strong>Monitor Performance and Logs</strong></p>



<p>In the immediate aftermath of the upgrade, closely monitor the system&#8217;s performance, including CPU, memory usage, and disk I/O, to identify any unexpected behavior or bottlenecks. Additionally, review the Cassandra system logs for warnings or errors that may indicate potential issues requiring attention.</p>



<p><strong>Tune and Optimize</strong></p>



<p>Based on the performance monitoring insights, you may need to adjust Cassandra&#8217;s configuration settings for optimal performance. Consider tuning parameters related to JVM options, compaction, and read/write performance, keeping in mind the specific workload and data patterns of your application.</p>



<p><strong>Run nodetool upgradesstables</strong></p>



<p>To ensure that all SSTables are updated to the latest format, execute <code>nodetool upgradesstables</code> on each node in the cluster. This operation will rewrite SSTables that are not already in the current format, which is essential for taking full advantage of the improvements and features in Cassandra 4.1.x (Check the space, and if required, delete all snapshots as shown above.):</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># time nodetool upgradesstables</pre></div>



<p>This process can be resource-intensive and should be scheduled during off-peak hours to minimize impact on live traffic.</p>



<p><strong>Implement Security Enhancements</strong></p>



<p>Cassandra 4.1.x includes several security enhancements. Review the latest security features and best practices, such as enabling client-to-node encryption, node-to-node encryption, and advanced authentication mechanisms, to enhance the security posture of your Cassandra cluster.</p>



<p><strong>Review and Update Backup Strategies</strong></p>



<p>With the new version in place, reassess your backup strategies to ensure they are still effective and meet your recovery objectives. Verify that your backup and restore procedures are compatible with Cassandra 4.1.x and consider leveraging new tools or features that may have been introduced in this release for more efficient data management.</p>
<p>Artykuł <a href="https://soban.pl/upgrading-apache-cassandra-from-version-3-1-15-and-higher-to-4-1-x-on-ubuntu-20-04-5-lts-a-comprehensive-guide/">Upgrading Apache Cassandra from Version 3.1.15 and Higher to 4.1.x on Ubuntu 20.04.5 LTS: A Comprehensive Guide</a> pochodzi z serwisu <a href="https://soban.pl">soban</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Proxy through nginx frontend to the second virtual server wordpress</title>
		<link>https://soban.pl/proxy-through-nginx-frontend-to-the-second-virtual-server-wordpress/</link>
		
		<dc:creator><![CDATA[soban]]></dc:creator>
		<pubDate>Sun, 07 Nov 2021 11:48:33 +0000</pubDate>
				<category><![CDATA[Debian]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Network]]></category>
		<category><![CDATA[Nginx]]></category>
		<category><![CDATA[Proxy]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Wordpress]]></category>
		<guid isPermaLink="false">https://soban.pl/?p=315</guid>

					<description><![CDATA[<p>In a situation where we have one public IP address and we have many domains directed to that IP address, it is worth considering spreading the traffic to other servers. Proxmox, which allows you to create a pair of virtual machines, is perfect in such a situation. In my case, each virtual machine is separated [&#8230;]</p>
<p>Artykuł <a href="https://soban.pl/proxy-through-nginx-frontend-to-the-second-virtual-server-wordpress/">Proxy through nginx frontend to the second virtual server wordpress</a> pochodzi z serwisu <a href="https://soban.pl">soban</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>In a situation where we have one public IP address and we have many domains directed to that IP address, it is worth considering spreading the traffic to other servers. Proxmox, which allows you to create a pair of virtual machines, is perfect in such a situation. In my case, each virtual machine is separated and the traffic is broken down by nginx, which distributes the traffic to other servers. The virtual machine on my website will redirect traffic, I have the IP address for wordpress: <strong>10.10.11.105 </strong>on port <strong>80</strong>. In this case, no encryption is required, but the frontend itself, which manages the traffic, will present itself with encryption and security on port <strong>443</strong>.</p>



<p>Two machines with the following configuration will participate throughout the process:<br><strong>up-page</strong> IP: <strong>10.10.14.200</strong><br><strong>soban-pl</strong> IP: <strong>10.10.11.105</strong></p>



<p>So let&#8217;s move on to the frontend that distributes traffic to other machines.<br>The frontend is done by linux debian 11 (bullseye), in addition, I have the following entry in the repository (<strong>/etc/apt/sources.list</strong>):</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">#...
deb http://nginx.org/packages/debian/ bullseye nginx
deb-src http://nginx.org/packages/debian/ bullseye nginx</pre></div>



<p>To install nginx, run the following commands:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># apt update
# apt install nginx</pre></div>



<p>You should make sure that the traffic from the frontend has the appropriate port 80 transitions. You can read how to check the network transitions here: <strong><a href="https://soban.pl/check-network-connection-and-open-tcp-port-via-netcat/" target="_blank" rel="noreferrer noopener">Check network connection and open TCP port via netcat</a></strong>.</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="469" height="154" src="https://soban.pl/wp-content/uploads/2021/11/image-18.png" alt="Screenshot of a terminal window showing a successful telnet connection to the IP address 10.10.11.105 on port 80, followed by the user exiting the telnet session with the 'quit' command." class="wp-image-317" srcset="https://soban.pl/wp-content/uploads/2021/11/image-18.png 469w, https://soban.pl/wp-content/uploads/2021/11/image-18-300x99.png 300w" sizes="auto, (max-width: 469px) 100vw, 469px" /></figure>



<p>The configuration of the frontend that distributes the traffic is as follows (<strong>/etc/nginx/conf.d/soban.pl.ssl.conf</strong>):</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">upstream soban-pl-webservers {
    server 10.10.11.105:80;
}

server {
    if ($host = www.soban.pl) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


    if ($host = soban.pl) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


        listen 80;
        server_name soban.pl www.soban.pl;
        return 301 https://soban.pl$request_uri;
}

server {
    listen 443 ssl http2;
    server_name  www.soban.pl;
    ssl_certificate /etc/letsencrypt/live/www.soban.pl/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/www.soban.pl/privkey.pem; # managed by Certbot
    ssl_protocols TLSv1.2 TLSv1.3;
    ssl_prefer_server_ciphers on;
    ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;
    return 301 https://soban.pl$request_uri;
}

server {
    listen 443 ssl http2;
    server_name  soban.pl _;
    ssl_certificate /etc/letsencrypt/live/soban.pl/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/soban.pl/privkey.pem; # managed by Certbot
    ssl_protocols TLSv1.2 TLSv1.3;
    ssl_prefer_server_ciphers on;
    ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;
}

    location / {
        access_log /var/log/nginx/access-soban.pl.log;
        error_log /var/log/nginx/error-soban.pl.log;
        proxy_pass http://soban-pl-webservers;
        proxy_redirect https://soban-pl-webservers http://soban-pl-webservers;
        expires off;

        proxy_read_timeout       3500;
        proxy_connect_timeout    3250;

        proxy_set_header   X-Real-IP          $remote_addr;
        proxy_set_header   Host               $host;
        proxy_set_header   X-Forwarded-For    $proxy_add_x_forwarded_for;
        proxy_set_header   X-Forwarded-Proto  https;
        proxy_set_header   SSL_PROTOCOL $ssl_protocol;
        proxy_set_header   SSL_CLIENT_CERT $ssl_client_cert;
        proxy_set_header   SSL_CLIENT_VERIFY $ssl_client_verify;
        proxy_set_header   SSL_SERVER_S_DN $ssl_client_s_dn;

                proxy_set_header X-Scheme $scheme;
                proxy_ssl_session_reuse off;
                proxy_http_version 1.1;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection "upgrade";
    }
      location ~ ^/(wp-admin|wp-login\.php) {
            auth_basic "Restricted";
            auth_basic_user_file /etc/nginx/conf.d/htpasswd;
           proxy_pass http://soban-pl-webservers;
           proxy_redirect https://soban-pl-webservers http://soban-pl-webservers;
           expires off;
           proxy_next_upstream error timeout invalid_header http_500 http_502 http_503;
           proxy_set_header        Host            $host;
           proxy_set_header        X-Real-IP       $remote_addr;
           proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
      }

}</pre></div>



<p>Configuration of the above-mentioned wordpress, additional authorization is also set when you try to log in to wp-admin, you can read about it here: <strong><a href="https://soban.pl/more-security-wp-admin-in-nginx/" target="_blank" rel="noreferrer noopener">More security wp-admin in nginx</a></strong>. </p>



<p>In the next step, check if the nginx configuration is correct by: </p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># service nginx configtest</pre></div>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="808" height="76" src="https://soban.pl/wp-content/uploads/2021/11/image-17.png" alt="Terminal output displaying a successful nginx configuration test with the messages: 'nginx: the configuration file /etc/nginx/nginx.conf syntax is ok' and 'nginx: configuration file /etc/nginx/nginx.conf test is successful'." class="wp-image-316" srcset="https://soban.pl/wp-content/uploads/2021/11/image-17.png 808w, https://soban.pl/wp-content/uploads/2021/11/image-17-300x28.png 300w, https://soban.pl/wp-content/uploads/2021/11/image-17-768x72.png 768w" sizes="auto, (max-width: 808px) 100vw, 808px" /></figure>



<p>If everything is fine, restart nginx:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># service nginx restart</pre></div>



<p>In a virtual machine with nginx it should also be installed. This is the same as debian linux 11 (bullseye), so the respository should look like this:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">#...
deb http://nginx.org/packages/debian/ bullseye nginx
deb-src http://nginx.org/packages/debian/ bullseye nginx</pre></div>



<p>Just installing nginx looks the same as on a machine that acts as a proxy.</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># apt update
# apt install nginx</pre></div>



<p>All configuration is in <strong>/etc/nginx/conf.d/soban.pl.conf</strong>:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">server {
    listen   80;

   client_max_body_size 20M;

    server_name soban.pl www.soban.pl;
    access_log /var/log/nginx/access-soban.pl.log; #access logi
    error_log /var/log/nginx/error-soban.log; # error logi
    port_in_redirect off;
    set_real_ip_from  10.10.11.105;
    real_ip_header    X-Forwarded-For;
    real_ip_recursive on;
       root /home/produkcja/wordpress/;
       index index.html index.php;

if ($host ~* ^www\.(.*))
{
    set $host_without_www $1;
    rewrite ^/(.*)$ $scheme://$host_without_www/$1 permanent;
}

    error_page 404 /index.php;


        location ~ \.php$ {
                root /home/produkcja/wordpress/; # dir where is wordpress
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
                fastcgi_pass unix:/var/run/php/php-fpm.sock;
                fastcgi_index index.php;
                include fastcgi_params;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

        }

        location / {
                try_files $uri $uri/ /index.php?$args;
        }
        location = /sitemap.xml {
                rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.xml$ "/index.php?xml_sitemap=params=$2" last;
                rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.xml\.gz$ "/index.php?xml_sitemap=params=$2;zip=true" last;
                rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.html$ "/index.php?xml_sitemap=params=$2;html=true" last;
                rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.html.gz$ "/index.php?xml_sitemap=params=$2;html=true;zip=true" last;
       }

location = /favicon.ico {
  return 204;
  access_log     off;
  log_not_found  off;
}

location ~* \.(jpg|jpeg|png|gif|ico|css|js)$ {
expires 365d;
        }location ~* \.(pdf)$ {
expires 30d;
}

}</pre></div>



<p>Also in this case, check the correctness of the nginx service configuration:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># service nginx configtest</pre></div>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="802" height="66" src="https://soban.pl/wp-content/uploads/2021/11/image-19.png" alt="" class="wp-image-318" srcset="https://soban.pl/wp-content/uploads/2021/11/image-19.png 802w, https://soban.pl/wp-content/uploads/2021/11/image-19-300x25.png 300w, https://soban.pl/wp-content/uploads/2021/11/image-19-768x63.png 768w" sizes="auto, (max-width: 802px) 100vw, 802px" /></figure>



<p>Everything looks fine, so let&#8217;s move on to restarting the service:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># service nginx restart</pre></div>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="806" height="71" src="https://soban.pl/wp-content/uploads/2021/11/image-20.png" alt="" class="wp-image-319" srcset="https://soban.pl/wp-content/uploads/2021/11/image-20.png 806w, https://soban.pl/wp-content/uploads/2021/11/image-20-300x26.png 300w, https://soban.pl/wp-content/uploads/2021/11/image-20-768x68.png 768w" sizes="auto, (max-width: 806px) 100vw, 806px" /></figure>



<p>If the whole configuration was done correctly, the page should be directed without encrypted traffic to the virtual machine with wordpress. A wordpress service with nginx is not the only one that can be hosted or proxied. We can direct traffic from nginx to e.g. jboss, apacha and all other web services. Of course, this requires a corresponding modification of the configuration presented above, but the general outline of the concept as an nginx proxy has been presented. You should also remember about the appropriate configuration of keys and certificates. In my case let&#8217;s encrypt works perfectly for this.</p>
<p>Artykuł <a href="https://soban.pl/proxy-through-nginx-frontend-to-the-second-virtual-server-wordpress/">Proxy through nginx frontend to the second virtual server wordpress</a> pochodzi z serwisu <a href="https://soban.pl">soban</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Improving encryption on old red hat 5 by new Oracle Linux 7 using apache mod_proxy</title>
		<link>https://soban.pl/improving-encryption-on-old-red-hat-5-by-new-oracle-linux-7-using-apache-mod_proxy/</link>
		
		<dc:creator><![CDATA[soban]]></dc:creator>
		<pubDate>Sat, 06 Nov 2021 13:54:17 +0000</pubDate>
				<category><![CDATA[Bash]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Network]]></category>
		<category><![CDATA[Oracle Linux]]></category>
		<category><![CDATA[Proxy]]></category>
		<category><![CDATA[Red Hat 5]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[SSL]]></category>
		<guid isPermaLink="false">https://soban.pl/?p=308</guid>

					<description><![CDATA[<p>There are situations when we need to increase the encryption level on the old system &#8211; according to the PCI audit requirements. However, the old system is no longer supported, so updating the encryption level is not possible. This is not a recommended solution, because we should try to transfer the application to a new [&#8230;]</p>
<p>Artykuł <a href="https://soban.pl/improving-encryption-on-old-red-hat-5-by-new-oracle-linux-7-using-apache-mod_proxy/">Improving encryption on old red hat 5 by new Oracle Linux 7 using apache mod_proxy</a> pochodzi z serwisu <a href="https://soban.pl">soban</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>There are situations when we need to increase the encryption level on the old system &#8211; according to the PCI audit requirements. However, the old system is no longer supported, so updating the encryption level is not possible. This is not a recommended solution, because we should try to transfer the application to a new system. After all, when we have little time, it is possible to hide the old version of the system and allow only the new machine to move to it. In this particular example, we will use mod_proxy as a proxy to redirect traffic to the old machine, while using iptables we will only allow communication with the new machine. It is not a recommended solution, but it works and I would like to present it here. The systems that I will be basing on in this example are the old <strong>red hat 5</strong> and the new <strong>oracle linux 7</strong>. Recently, it has become very important to use a minimum of <strong>tls 1.2</strong> and none below for banking transactions. Let&#8217;s start with the proxy server configuration <strong>oracle linux 7</strong>.</p>



<p>As of this writing, the addressing is as follows:<br><strong>new_machine</strong> IP: <strong>10.10.14.100</strong><br><strong>old_machine</strong> IP: <strong>10.10.14.101</strong><br>Traffic will be routed on port 443 from new_machine to old_machine.</p>



<p>Before we go to proxy configuration, please make sure there are network transitions from new_machine (10.10.14.100) to old_machine (10.10.14.101) to port 443. You can read how to verify network connections here: <strong><a href="https://soban.pl/check-network-connection-and-open-tcp-port-via-netcat/" target="_blank" rel="noreferrer noopener">check network connection and open tcp port via netcat</a></strong>.</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="544" height="51" src="https://soban.pl/wp-content/uploads/2021/11/image-13.png" alt="" class="wp-image-309" srcset="https://soban.pl/wp-content/uploads/2021/11/image-13.png 544w, https://soban.pl/wp-content/uploads/2021/11/image-13-300x28.png 300w" sizes="auto, (max-width: 544px) 100vw, 544px" /></figure>



<p>We go to the installation of apache and mod_proxy:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># yum install httpd mod_proxy</pre></div>



<p>After installing apache, go to the edition:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># vi /etc/httpd/conf.d/ssl.conf</pre></div>



<p>Below are the news on the check level, what are the updates, and ip on the next service update:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">&lt;VirtualHost _default_:443&gt;
SSLProtocol -all +TLSv1.2
SSLCipherSuite ALL:!aNULL:!ADH:!eNULL:!LOW:!EXP:!NULL:!RC4:!RC2:!DES:!3DES:!SHA:!SHA256:!SHA384:!MD5+HIGH:+MEDIUM:!KRB5
#…
&lt;IfModule mod_proxy.c&gt;
SSLProxyProtocol all
SSLProxyEngine on
SSLProxyCheckPeerCN off
SSLProxyCheckPeerName off
SSLProxyCheckPeerExpire off
ProxyRequests On
    &lt;Proxy *&gt;
        Require all granted
    &lt;/Proxy&gt;
    # backend server and forwarded path
    ProxyPass / https://10.10.14.101/
    ProxyPassReverse / https://10.10.14.101/
&lt;/IfModule&gt;
&lt;/VirtualHost&gt;</pre></div>



<p>In order to verify the correctness of apache configuration, you can issue a command that will check it:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># service httpd configtest</pre></div>



<p>If the apache configuration is correct, we can proceed to reloading apache:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># service httpd restart</pre></div>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="621" height="50" src="https://soban.pl/wp-content/uploads/2021/11/image-14.png" alt="" class="wp-image-310" srcset="https://soban.pl/wp-content/uploads/2021/11/image-14.png 621w, https://soban.pl/wp-content/uploads/2021/11/image-14-300x24.png 300w" sizes="auto, (max-width: 621px) 100vw, 621px" /></figure>



<p>At this point, we have a configured proxy connection. Before we move on to limiting traffic with iptables, I suggest you go to the site &#8211; with the new mod_proxy configured and test if everything is working properly and if there are any problems with the application.</p>



<p>Once everything is working fine, the network transitions are there, we can go to the iptables configuration for red hat 5. Let&#8217;s start by checking the system version:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># cat /etc/redhat-release</pre></div>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="663" height="48" src="https://soban.pl/wp-content/uploads/2021/11/image-15.png" alt="" class="wp-image-311" srcset="https://soban.pl/wp-content/uploads/2021/11/image-15.png 663w, https://soban.pl/wp-content/uploads/2021/11/image-15-300x22.png 300w" sizes="auto, (max-width: 663px) 100vw, 663px" /></figure>



<p>Now we are going to prepare iptables so that the network traffic is available on port 443 from the new_machine (10.10.14.100). To do this, edit the file <strong>/etc/sysconfig/iptables</strong>:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -p tcp --dport 443 -s 10.10.14.100 -j ACCEPT
-A INPUT -p tcp --dport 443 -j DROP
-A INPUT -p tcp --dport 80 -j DROP
-A INPUT -j ACCEPT
COMMIT</pre></div>



<p>After iptables settings are correct, we can reload the service:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># /etc/init.d/iptables restart</pre></div>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="886" height="153" src="https://soban.pl/wp-content/uploads/2021/11/image-16.png" alt="" class="wp-image-313" srcset="https://soban.pl/wp-content/uploads/2021/11/image-16.png 886w, https://soban.pl/wp-content/uploads/2021/11/image-16-300x52.png 300w, https://soban.pl/wp-content/uploads/2021/11/image-16-768x133.png 768w" sizes="auto, (max-width: 886px) 100vw, 886px" /></figure>



<p>In this way, we managed to cover up the weak encryption by proxying and diverting traffic to the new machine. This is not a recommended solution and you should try to transfer the application to a new environment compatible with the new system. However, in crisis situations, we can use this solution. Network traffic is not allowed by other IP addresses, so scanners will not be able to detect weak encryption on the old machine, and users using the old environment will not be able to use it. This does not change the fact that weak encryption is still set in the old environment and needs to be corrected. The example I gave is for the old <strong>red hat 5</strong> and the new <strong>oracle linux 7</strong>, but it can be assumed that a similar solution and configuration is possible for other versions of the system.</p>
<p>Artykuł <a href="https://soban.pl/improving-encryption-on-old-red-hat-5-by-new-oracle-linux-7-using-apache-mod_proxy/">Improving encryption on old red hat 5 by new Oracle Linux 7 using apache mod_proxy</a> pochodzi z serwisu <a href="https://soban.pl">soban</a>.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
