<?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: samnang rosady</title>
    <description>The latest articles on DEV Community by samnang rosady (@medrix).</description>
    <link>https://dev.to/medrix</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%2F1770314%2F12d0b173-5dc0-4346-b300-d1f7b5996f4c.jpeg</url>
      <title>DEV Community: samnang rosady</title>
      <link>https://dev.to/medrix</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/medrix"/>
    <language>en</language>
    <item>
      <title>Redis Commander</title>
      <dc:creator>samnang rosady</dc:creator>
      <pubDate>Fri, 15 Aug 2025 11:29:13 +0000</pubDate>
      <link>https://dev.to/medrix/redis-commander-401g</link>
      <guid>https://dev.to/medrix/redis-commander-401g</guid>
      <description>&lt;h3&gt;
  
  
  🔍 What is Redis Commander?
&lt;/h3&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%2Fz69jo5w0ytc8copuockz.webp" 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%2Fz69jo5w0ytc8copuockz.webp" alt=" " width="800" height="541"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;Redis Commander&lt;/strong&gt; is a lightweight, open-source web-based GUI for managing Redis databases. It allows users to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Browse and query keys&lt;/li&gt;
&lt;li&gt;View and edit key values&lt;/li&gt;
&lt;li&gt;Add or delete keys&lt;/li&gt;
&lt;li&gt;Monitor Redis memory usage&lt;/li&gt;
&lt;li&gt;Connect to remote or local Redis instances
Redis Commander runs as a web server, and once it's up and running, you can access it through your browser.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  ❓ Why Use Redis Commander?
&lt;/h2&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%2Fx4inq49pnm8ugc8fa1ts.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%2Fx4inq49pnm8ugc8fa1ts.png" alt=" " width="800" height="129"&gt;&lt;/a&gt;&lt;br&gt;
While Redis CLI is fast and flexible, it can be intimidating for beginners and time-consuming for more complex operations. &lt;br&gt;
Redis Commander provides a user-friendly interface, and based on Node.js.&lt;/p&gt;

&lt;h2&gt;
  
  
  ⚙️ Features:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Simple and user-friendly interface&lt;/li&gt;
&lt;li&gt;Supports basic key management tasks&lt;/li&gt;
&lt;li&gt;Built-in command console&lt;/li&gt;
&lt;li&gt;Customizable themes&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  🤔 Pros and Cons
&lt;/h2&gt;

&lt;h3&gt;
  
  
  👍🏼 Pros:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Free and open-source&lt;/li&gt;
&lt;li&gt;Easy to learn and use&lt;/li&gt;
&lt;li&gt;Lightweight and portable&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  👎🏼 Cons:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Lacks some advanced features found in other tools&lt;/li&gt;
&lt;li&gt;Limited customization options&lt;/li&gt;
&lt;li&gt;May not be suitable for very large datasets&lt;/li&gt;
&lt;li&gt;Performance can be impacted by the web interface&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  💻 Available on:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Windows&lt;/li&gt;
&lt;li&gt;macOS&lt;/li&gt;
&lt;li&gt;Linux&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>redis</category>
      <category>monitoring</category>
    </item>
    <item>
      <title>Jinja: The Templating Wizard That Saves Devs From Keyboard Trauma</title>
      <dc:creator>samnang rosady</dc:creator>
      <pubDate>Thu, 08 May 2025 16:37:58 +0000</pubDate>
      <link>https://dev.to/medrix/jinja-the-templating-wizard-that-saves-devs-from-keyboard-trauma-55n6</link>
      <guid>https://dev.to/medrix/jinja-the-templating-wizard-that-saves-devs-from-keyboard-trauma-55n6</guid>
      <description>&lt;h3&gt;
  
  
  💡 What is Jinja?
&lt;/h3&gt;

&lt;p&gt;🧙‍♂️ Jinja is a modern and designer-friendly templating language for Python, used to generate files dynamically. Think of it like &lt;strong&gt;Mad Libs&lt;/strong&gt; for config files, where you can inject variables into a template and programmatically generate output.&lt;/p&gt;

&lt;p&gt;It’s used heavily in:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Any scenario where you want to avoid copy-paste hell 🔥&lt;/li&gt;
&lt;li&gt;Infrastructure as Code (Ansible, SaltStack)&lt;/li&gt;
&lt;li&gt;Web frameworks (like Flask or Django)&lt;/li&gt;
&lt;li&gt;Easy to learn if you have experience some template engine such as Laravel Blade, Twig, Haml, 11ty&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  🎯 Why Use Jinja?
&lt;/h3&gt;

&lt;p&gt;Use Jinja when you want to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Reduce human errors by avoiding repetitive copy-paste&lt;/li&gt;
&lt;li&gt;Dynamically change parameters like server names, ports, or environments&lt;/li&gt;
&lt;li&gt;Reusable: You can write once and render thousands of variations. Efficiency FTW.&lt;/li&gt;
&lt;li&gt;Clean separation: Keeps logic out of your final output, whether it’s HTML or NGINX configs.&lt;/li&gt;
&lt;li&gt;CLI support (jinja-cli)&lt;/li&gt;
&lt;li&gt;Make your deployments look like wizardry ✨&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  ❌ Don't Use Jinja
&lt;/h4&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;When...&lt;/th&gt;
&lt;th&gt;Why&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;You only need &lt;strong&gt;one or two&lt;/strong&gt; static files&lt;/td&gt;
&lt;td&gt;Overkill. Just use Vim and be done.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;You need &lt;strong&gt;real-time updates&lt;/strong&gt; (e.g. hot reload UIs)&lt;/td&gt;
&lt;td&gt;Jinja is static. It renders once and that's it.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Your team has &lt;strong&gt;zero Python experience&lt;/strong&gt;
&lt;/td&gt;
&lt;td&gt;Might be a steep ramp-up.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;You want &lt;strong&gt;complex business logic&lt;/strong&gt; in templates&lt;/td&gt;
&lt;td&gt;Templates are not codebases! 🤯&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h4&gt;
  
  
  Example: Automating NGINX Config with Jinja
&lt;/h4&gt;

&lt;p&gt;Let’s break it down with an imaginative metaphor:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Using &lt;code&gt;vim&lt;/code&gt; for 1,000 NGINX config files is like writing wedding invitations by hand. Sweet, but painful."&lt;br&gt;
&lt;strong&gt;Jinja&lt;/strong&gt; is like a laser printer with your best handwriting.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Scenario:&lt;br&gt;
You run a massive &lt;strong&gt;fleet of servers&lt;/strong&gt; and each one needs its own NGINX configuration:&lt;/p&gt;
&lt;h5&gt;
  
  
  Without &lt;strong&gt;Jinja&lt;/strong&gt;:
&lt;/h5&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;→ vim  
 → Modify 
  → Save
→ Repeat 999 times 🔁
 → Cry 😭
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h5&gt;
  
  
  With &lt;strong&gt;Jinja&lt;/strong&gt;:
&lt;/h5&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%2F5nslta8uii2arezde4wj.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%2F5nslta8uii2arezde4wj.png" alt=" "&gt;&lt;/a&gt;&lt;br&gt;
You write &lt;strong&gt;one&lt;/strong&gt; template:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# nginx_template.j2
upstream {{ upstream }} {
  {% for upstream_item in upstream_servers%}
    {{- upstream_item }};
  {% endfor %}
}

server {
  listen 80;
  server_name {{ domain_name }};
  rewrite ^(.*) https://$host$1 permanent;
}

server {
  listen 443 ssl http2;
  listen [::]:443 ssl http2;
  server_name {{ domain_name }};

  server_tokens off;
  ssl_certificate /etc/letsencrypt/live/{{ domain_name }}/fullchain.pem;
  ssl_certificate_key /etc/letsencrypt/live/{{ domain_name }}/privkey.pem;

  client_max_body_size 50M;

  access_log /var/log/nginx/{{ domain_name }}-access.log;
  error_log /var/log/nginx/{{ domain_name }}-error.log;

  {%- if auth %}
  auth_basic {{ auth.auth_basic }};
  auth_basic_user_file {{ auth.auth_user_file }};
  {% endif -%}

  location / {
    access_log /var/log/nginx/{{ domain_name }}-access.log;
    proxy_pass {{ upstream }};
    proxy_redirect off;

    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header X-Forwarded-Host $host;
    proxy_set_header X-Forwarded-Port $server_port;
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With dynamic data with json&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;app.local.json
{
  "domain_name" : "app.local",
  "upstream" : "http://proxy-app",
  "upstream_servers" : [
    "server 10.143.41.104:8081",
    "server 10.143.41.104:8082",
    "server 10.143.41.104:8083"
  ],
  "auth" : {
    "auth_basic" : "Restricted Area",
    "auth_user_file" : "/etc/nginx/htpasswd/auth"
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run-time 🏃&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;jinja2 ./nginx_template.j2 ./app.local.json --format=json --outfile=./app.local.conf
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now you’ve got a thousand configs generated faster than a barista can spell your name wrong.&lt;/p&gt;

&lt;h3&gt;
  
  
  Final Thoughts
&lt;/h3&gt;

&lt;p&gt;Jinja is the &lt;strong&gt;unsung hero&lt;/strong&gt; of DevOps, backend automation, and lazy (smart) developers everywhere. It’s not flashy, but it’s reliable, fast, and scales beautifully. 🚀&lt;/p&gt;

&lt;p&gt;Use it wisely — and maybe, just maybe, save your fingers from vim-induced arthritis.&lt;/p&gt;




&lt;p&gt;&lt;a href="https://github.com/misterfrenky/jinja2-sample" rel="noopener noreferrer"&gt;GitHub Sample Repository 🐳&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Enjoy you practice 🌟&lt;/p&gt;

</description>
      <category>jinja</category>
      <category>devops</category>
      <category>automation</category>
    </item>
    <item>
      <title>A Guide to Setting Up Local HTTPS Portals with Docker</title>
      <dc:creator>samnang rosady</dc:creator>
      <pubDate>Fri, 02 May 2025 03:16:21 +0000</pubDate>
      <link>https://dev.to/medrix/a-guide-to-setting-up-local-https-portals-with-docker-1aj9</link>
      <guid>https://dev.to/medrix/a-guide-to-setting-up-local-https-portals-with-docker-1aj9</guid>
      <description>&lt;h3&gt;
  
  
  Understanding Local HTTPS Portals
&lt;/h3&gt;

&lt;p&gt;Local HTTPS portals enable developers to create secure connections within their development environments. By utilizing HTTPS, data transmitted between services remains encrypted, safeguarding sensitive information from potential security threats.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why Use Local HTTPS Portals with Docker?
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Enhanced Security:&lt;/strong&gt; HTTPS encryption protects data integrity and confidentiality, crucial for handling sensitive information during development.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Realistic Testing Environment:&lt;/strong&gt; Mimicking production environments with HTTPS setups ensures more accurate testing, reducing the likelihood of issues when deploying to live servers.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Streamlined Development Workflow:&lt;/strong&gt; Docker's containerization capabilities facilitate easy setup and teardown of services, making it effortless to create and manage secure development environments.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Collaboration and Consistency:&lt;/strong&gt; By standardizing HTTPS setups with Docker, developers can collaborate seamlessly and ensure consistent configurations across team members.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Practice
&lt;/h3&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%2Fj67969n2b4n1jemhugsm.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%2Fj67969n2b4n1jemhugsm.png" alt="Image description" width="800" height="414"&gt;&lt;/a&gt;&lt;br&gt;
Imagine you have local services frontend and API running on ports 3000 and 3001, respectively. You want to set up a local HTTPS portal using Docker to secure these services. You want access &lt;code&gt;https://api.local.test&lt;/code&gt; for the API and &lt;code&gt;https://front.local.test&lt;/code&gt; for the frontend.&lt;/p&gt;
&lt;h4&gt;
  
  
  Docker
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;docker-compose.yml&lt;/strong&gt;
Create a &lt;code&gt;docker-compose.yml&lt;/code&gt; file to define the services and their configurations.
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;services:
  frontend:
    container_name: frontend
    image: nginxdemos/hello
    ports:
      - "3000:80"

  api:
    container_name: api
    image: nmatsui/hello-world-api
    ports:
      - "3001:3000"

  https-portal:
    image: steveltn/https-portal:1
    ports:
      - "80:80"
      - "443:443"
    restart: always
    environment:
      DOMAINS: 'api.local.test -&amp;gt; http://api:3001, front.local.test -&amp;gt; http://frontend:80'
    volumes:
      - https-portal-data:/var/lib/https-portal

volumes:
  https-portal-data:
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h4&gt;
  
  
  Update your system's hosts file to point the domains to your Docker host
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Linux/MacOS&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;echo "127.0.0.1       local.test api.local.test" | sudo tee -a /etc/hosts
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Windows&lt;/strong&gt;: On Windows: Add these lines to C:\Windows\System32\drivers\etc\hosts
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;127.0.0.1 local.test
127.0.0.1 api.local.test
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;Run&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker compose up -d
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;Enjoy your practice 🌟&lt;/p&gt;

</description>
      <category>docker</category>
      <category>devops</category>
      <category>security</category>
    </item>
    <item>
      <title>Rclone: Cloudflare R2 and Nginx Reverse Proxy</title>
      <dc:creator>samnang rosady</dc:creator>
      <pubDate>Mon, 24 Mar 2025 06:16:09 +0000</pubDate>
      <link>https://dev.to/medrix/rclone-cloudflare-r2-and-nginx-reverse-proxy-509b</link>
      <guid>https://dev.to/medrix/rclone-cloudflare-r2-and-nginx-reverse-proxy-509b</guid>
      <description>&lt;p&gt;Rclone is a powerful command-line tool that allows you to sync, copy, and manage files across multiple cloud storage providers. Cloudflare R2 is an object storage service designed to provide low-latency, high-availability storage without egress fees. By integrating Rclone with Cloudflare R2, you can efficiently manage your cloud storage with ease.&lt;/p&gt;

&lt;h3&gt;
  
  
  Installation
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo yum install epel-release
sudo yum -y install fuse rclone -y
ln -s /bin/fusermount /bin/fusermount3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Rclone config
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;vim ~/.config/rclone/rclone.conf
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;rclone.conf
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[r2demo]
type = s3
provider = Cloudflare
access_key_id = xxx
secret_access_key = xxxx
endpoint = xxxxx
region = auto
acl = private"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Rclone mount &lt;strong&gt;R2 remote&lt;/strong&gt; to &lt;strong&gt;local&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Option 1 (Debugging):&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;rclone mount r2demo:&amp;lt;bucket-name&amp;gt; &amp;lt;local-destination&amp;gt; --vfs-cache-mode off --log-file rclone.log  --log-level DEBUG
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Option 2:&lt;/strong&gt;&lt;br&gt;
Run in the background&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;nohup rclone mount r2demo:&amp;lt;bucket-name&amp;gt; &amp;lt;local-destination&amp;gt; --vfs-cache-mode off --log-file /var/log/rclone.log --log-level NOTICE &amp;gt; /dev/null 2&amp;gt;&amp;amp;1 &amp;amp;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Using &lt;em&gt;--log-file&lt;/em&gt;, in case of debugging.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;--log-level LEVEL&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;DEBUG&lt;/strong&gt; is equivalent to -vv. It outputs lots of debug info - useful for bug reports and really finding out what rclone is doing.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;INFO&lt;/strong&gt; is equivalent to -v. It outputs information about each transfer and prints stats once a minute by default.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;NOTICE&lt;/strong&gt; is the default log level if no logging flags are supplied. It outputs very little when things are working normally. It outputs warnings and significant events.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;h3&gt;
  
  
  Symlink
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ln -s &amp;lt;local-destination&amp;gt; &amp;lt;project-storage-destination&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Nginx reverse proxy
&lt;/h3&gt;

&lt;p&gt;✅ Faster global delivery due to Cloudflare’s CDN caching.&lt;br&gt;
✅ Potential cost savings by reducing server bandwidth usage.&lt;br&gt;
✅ Decreased load on server, especially for high-traffic websites.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;map $uri $new_uploads_uri {
  ~^/&amp;lt;storage-uri&amp;gt;/(.*)$ //$1;
}
server {
  .....
  location ^~ /&amp;lt;storage-uri&amp;gt;/ {
     resolver 1.1.1.1;
     proxy_ssl_server_name on;
     proxy_pass https://&amp;lt;public-r2-domain&amp;gt;$new_uploads_uri;
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Sample: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&amp;lt; storage-uri &amp;gt;&lt;/strong&gt;: &lt;code&gt;wp-content/upload&lt;/code&gt;.
We want to reverse from &lt;code&gt;$HOST/wp-content/upload/xxx/xxx/xxx.jpg&lt;/code&gt; to &lt;code&gt;&amp;lt;public-r2-domain&amp;gt;/upload/xxx/xxx/xxx.jpg&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;By combining Rclone, Nginx, and Cloudflare R2, you can serve static files efficiently with:&lt;br&gt;
✅ Custom domain support&lt;br&gt;
✅ SSL encryption&lt;br&gt;
✅ Caching &amp;amp; compression&lt;br&gt;
✅ No egress fees&lt;/p&gt;

&lt;p&gt;🌟 Stay tuned 🌟&lt;/p&gt;

</description>
      <category>rclone</category>
      <category>r2</category>
      <category>nginx</category>
      <category>cloud</category>
    </item>
    <item>
      <title>Gitlab CI/CD Auto-Pull</title>
      <dc:creator>samnang rosady</dc:creator>
      <pubDate>Wed, 19 Mar 2025 05:33:45 +0000</pubDate>
      <link>https://dev.to/medrix/gitlab-cicd-auto-pull-3ojg</link>
      <guid>https://dev.to/medrix/gitlab-cicd-auto-pull-3ojg</guid>
      <description>&lt;p&gt;&lt;strong&gt;GitLab CI/CD Auto-Pull&lt;/strong&gt; is a technique that allows your remote server to automatically pull the latest code changes whenever updates are pushed to a GitLab repository. This eliminates the need for manual intervention in deployments, making the process seamless and efficient.&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%2Fgxgpgxm1p0z4vzj23agv.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%2Fgxgpgxm1p0z4vzj23agv.png" alt="Image description" width="800" height="384"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Why Use Auto-Pull in GitLab CI/CD? 🚀
&lt;/h4&gt;

&lt;p&gt;Manually logging into a server and pulling new code updates can be tedious and error-prone. Automating this process offers several benefits:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;✅ Efficiency – No need to manually pull changes after every commit.&lt;/li&gt;
&lt;li&gt;✅ Consistency – Ensures that the correct version of the code is deployed.&lt;/li&gt;
&lt;li&gt;✅ Reduced Human Error – Eliminates the risk of forgetting to pull updates.&lt;/li&gt;
&lt;li&gt;✅ Faster Deployments – Code updates are available on the server as soon as they are pushed.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  1. Get SSH Access:
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;How to get openssh-private-key&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Test SSH Access&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ssh &amp;lt;linux-user&amp;gt;@&amp;lt;PRODUCTION_IP&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Get &lt;strong&gt;openssh-private-key&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ssh -o StrictHostKeyChecking=no ssh &amp;lt;linux-user&amp;gt;@&amp;lt;PRODUCTION_IP&amp;gt; "cat ~/.ssh/id_rsa"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;Value should be:&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;-----BEGIN OPENSSH PRIVATE KEY-----
....
-----END OPENSSH PRIVATE KEY-----
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2. Set variables credential:
&lt;/h3&gt;

&lt;p&gt;Go to &lt;strong&gt;GitLab Project&lt;/strong&gt; → &lt;strong&gt;Settings&lt;/strong&gt; → &lt;strong&gt;CI/CD&lt;/strong&gt; → &lt;strong&gt;Variables&lt;/strong&gt;&lt;br&gt;
You can add credential variable there. &lt;br&gt;
For example: &lt;code&gt;openssh-private-key&lt;/code&gt; (PROD_SSH_PRIVATE_KEY).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;PROD_SSH_PRIVATE_KEY:&lt;/strong&gt; Should &lt;code&gt;openssh-private-key&lt;/code&gt; of &lt;code&gt;&amp;lt;linux-user&amp;gt;&lt;/code&gt; which accessable to project directory, should not be root user.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Key: PROD_SSH_PRIVATE_KEY
Value: &amp;lt;openssh-private-key&amp;gt;
Type: Variable
Environment scope: All (default)
Protect variable: Checked
Mask variable: Checked
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Create &lt;code&gt;.gitlab-ci.yml&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;Go to &lt;strong&gt;GitLab Project&lt;/strong&gt; → &lt;strong&gt;Build&lt;/strong&gt; → &lt;strong&gt;Pipeline editor&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;variables:
  DOCKER_HOST: tcp://docker:2375
  SSH_USER: &amp;lt;linux-user&amp;gt;
  PRODUCTION_IP: &amp;lt;server-ip: xx.xx.xx.xx&amp;gt;

services:
  - docker:dind

stages:
  - deploy_production

deploy-prod:
  stage: deploy_production
  image: alpine:latest
  before_script:
    - apk add openssh-client openssh
    - eval $(ssh-agent -s)
    - echo "$PROD_SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
    - mkdir -p ~/.ssh
    - chmod 700 ~/.ssh
  script:
    - echo -e "This CI job deploys Stage= [$CI_JOB_STAGE], Branch= [$CI_COMMIT_BRANCH], Server IP= [$PRODUCTION_IP]"
    - ssh -o StrictHostKeyChecking=no ${SSH_USER}@${PRODUCTION_IP} -p 22 "cd &amp;lt;project-path&amp;gt; &amp;amp;&amp;amp; git pull origin &amp;lt;branch&amp;gt;"
    - echo -e "\033[0;32mPulled [$CI_COMMIT_BRANCH] \033[0m"
  rules:
    - if: '$CI_COMMIT_BRANCH == "&amp;lt;branch&amp;gt;"'
      when: manual
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;🌟 Stay tuned 🌟&lt;/p&gt;

</description>
      <category>gitlab</category>
      <category>automation</category>
      <category>devops</category>
    </item>
    <item>
      <title>Fail2ban</title>
      <dc:creator>samnang rosady</dc:creator>
      <pubDate>Wed, 29 Jan 2025 04:56:18 +0000</pubDate>
      <link>https://dev.to/medrix/fail2ban-1743</link>
      <guid>https://dev.to/medrix/fail2ban-1743</guid>
      <description>&lt;h3&gt;
  
  
  What is Fail2ban?
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Fail2Ban&lt;/strong&gt; is a free, open-source software tool that protects servers from brute-force attacks and other types of malicious activity. It monitors log files for suspicious activity and blocks IP addresses that are trying to access a server.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why use Fail2ban?
&lt;/h3&gt;

&lt;p&gt;There are several reasons to use Fail2ban:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Prevents brute force attacks on services&lt;/li&gt;
&lt;li&gt;Reduces server load from automated login attempts&lt;/li&gt;
&lt;li&gt;Provides an extra layer of security beyond firewalls&lt;/li&gt;
&lt;li&gt;Notify when there is an IP is ban/unban through SMTP, Webhook&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  How it works
&lt;/h3&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%2F50ze1mb45y255qkmokhl.jpeg" 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%2F50ze1mb45y255qkmokhl.jpeg" alt="Image description" width="800" height="800"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Fail2Ban scans log files for suspicious activity, such as too many access, failed attempts through access or error files&lt;/li&gt;
&lt;li&gt;Fail2Ban creates a firewall rule to block the IP address that is causing the suspicious activity &lt;/li&gt;
&lt;li&gt;The IP address is blocked for a specified amount of time&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Basic understanding Fail2ban
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Jails:
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Jails serve as rule sets that dictate the conditions under which an IP address should face a ban which defined by monitoring log files &lt;/li&gt;
&lt;li&gt;Predefined jail configurations can be found in &lt;code&gt;/etc/fail2ban/jail.conf&lt;/code&gt; within Fail2ban&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Filters:
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Filters are instrumental in scrutinizing service logs using regex patterns to identify potentially malicious activities, like intrusion attempts.&lt;/li&gt;
&lt;li&gt;These filters are typically stored in &lt;code&gt;/etc/fail2ban/filter.d/&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Actions:
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Actions encompass a range of responses, from IP address bans to notifications and the execution of custom scripts&lt;/li&gt;
&lt;li&gt;Commands outlining ban or unban procedures for IP addresses are typically housed in &lt;code&gt;/etc/fail2ban/action.d/&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;a href="https://github.com/misterfrenky/Fail2ban-Sample" rel="noopener noreferrer"&gt;GitHub Sample Repository 🐳&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Enjoy you practice 🌟&lt;/p&gt;

</description>
      <category>devops</category>
      <category>linux</category>
      <category>security</category>
    </item>
    <item>
      <title>nginx-mod-http-geoip</title>
      <dc:creator>samnang rosady</dc:creator>
      <pubDate>Wed, 15 Jan 2025 03:02:35 +0000</pubDate>
      <link>https://dev.to/medrix/nginx-mod-http-geoip-66b</link>
      <guid>https://dev.to/medrix/nginx-mod-http-geoip-66b</guid>
      <description>&lt;h2&gt;
  
  
  nginx-mod-http-geoip
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;nginx-mod-http-geoip&lt;/code&gt; is an nginx module that allows you to determine the geographical location of an IP address. The geo of country is presented by &lt;strong&gt;Alpha-2 code&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;You can find ISO  &lt;a href="https://www.iso.org/obp/ui/#search" rel="noopener noreferrer"&gt;ISO’s full, searchable list of all country codes&lt;/a&gt; to find your code.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight mathematica"&gt;&lt;code&gt;&lt;span class="nv"&gt;map&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;$geoip&lt;/span&gt;&lt;span class="o"&gt;_&lt;/span&gt;&lt;span class="nv"&gt;country&lt;/span&gt;&lt;span class="o"&gt;_&lt;/span&gt;&lt;span class="nv"&gt;code&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;$allowed&lt;/span&gt;&lt;span class="o"&gt;_&lt;/span&gt;&lt;span class="nv"&gt;country&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nv"&gt;default&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;no&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nv"&gt;RU&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;yes&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;#&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nv"&gt;ISO&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;3166&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;alpha&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="m"&gt;2&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nv"&gt;yes&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nv"&gt;no&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="nv"&gt;server&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="o"&gt;...&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nv"&gt;if&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$allowed&lt;/span&gt;&lt;span class="o"&gt;_&lt;/span&gt;&lt;span class="nv"&gt;country&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;no&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nv"&gt;return&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;403&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="o"&gt;...&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;&lt;a href="https://github.com/misterfrenky/ngx_geo" rel="noopener noreferrer"&gt;GitHub Sample Repository 🐳&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Enjoy you practice 🌟 &lt;/p&gt;

</description>
      <category>nginx</category>
      <category>infrastructure</category>
    </item>
    <item>
      <title>ngx whitelist/blacklist module</title>
      <dc:creator>samnang rosady</dc:creator>
      <pubDate>Tue, 14 Jan 2025 09:09:24 +0000</pubDate>
      <link>https://dev.to/medrix/ngx-whitelistblacklist-module-ngx-mod-http-geoip-module-4pm8</link>
      <guid>https://dev.to/medrix/ngx-whitelistblacklist-module-ngx-mod-http-geoip-module-4pm8</guid>
      <description>&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%2Fz4061xeh86z13rm44u1r.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%2Fz4061xeh86z13rm44u1r.png" alt="Image description" width="800" height="798"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;ngx whitelist/blacklist module&lt;/code&gt; in nginx provides a straightforward way to restrict or permit access to your server based on the IP address of the client making the request. You can define specific IP addresses or ranges in your configuration to either allow or deny access to your server resources.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;ngx_http_geo_module&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;http_geo_module module creates variables with values depending on the client IP address. That means &lt;code&gt;$c_ip_addr&lt;/code&gt; set value from ip value in file.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;/etc/nginx/ip_rules/ips.conf
&lt;/li&gt;
&lt;/ul&gt;

&lt;pre class="highlight plaintext"&gt;&lt;code&gt;163.38.139.42       1;
15.228.203.250      1;
146.16.251.134      0;
&lt;/code&gt;&lt;/pre&gt;



&lt;ul&gt;
&lt;li&gt;/etc/nginx/sites-available/
&lt;/li&gt;
&lt;/ul&gt;

&lt;pre class="highlight mathematica"&gt;&lt;code&gt;&lt;span class="nv"&gt;geo&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;$c&lt;/span&gt;&lt;span class="o"&gt;_&lt;/span&gt;&lt;span class="nv"&gt;ip&lt;/span&gt;&lt;span class="o"&gt;_&lt;/span&gt;&lt;span class="nv"&gt;addr&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nv"&gt;default&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nv"&gt;include&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nv"&gt;etc&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nv"&gt;nginx&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nv"&gt;ip&lt;/span&gt;&lt;span class="o"&gt;_&lt;/span&gt;&lt;span class="nv"&gt;rules&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nv"&gt;ips&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="nv"&gt;conf&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="nv"&gt;server&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nv"&gt;listen&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;80&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nv"&gt;server&lt;/span&gt;&lt;span class="o"&gt;_&lt;/span&gt;&lt;span class="nv"&gt;name&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;_;&lt;/span&gt;&lt;span class="w"&gt;

  &lt;/span&gt;&lt;span class="nv"&gt;if&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$c&lt;/span&gt;&lt;span class="o"&gt;_&lt;/span&gt;&lt;span class="nv"&gt;ip&lt;/span&gt;&lt;span class="o"&gt;_&lt;/span&gt;&lt;span class="nv"&gt;addr&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nv"&gt;return&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;403&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;

  &lt;/span&gt;&lt;span class="nv"&gt;location&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;

  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;




&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;&lt;strong&gt;Restricting Access &lt;code&gt;ngx_http_access_module&lt;/code&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;/etc/nginx/ip_rules/ip_block_rules.conf
&lt;/li&gt;
&lt;/ul&gt;

&lt;pre class="highlight mathematica"&gt;&lt;code&gt;&lt;span class="nv"&gt;allow&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;192.168.1.1&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="nv"&gt;allow&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;10.10.10.0&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="m"&gt;24&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="nv"&gt;allow&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;203.0.113.0&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="m"&gt;24&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;



&lt;ul&gt;
&lt;li&gt;/etc/nginx/sites-available/
&lt;/li&gt;
&lt;/ul&gt;

&lt;pre class="highlight mathematica"&gt;&lt;code&gt;&lt;span class="nv"&gt;server&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nv"&gt;listen&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;80&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nv"&gt;server&lt;/span&gt;&lt;span class="o"&gt;_&lt;/span&gt;&lt;span class="nv"&gt;name&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;nest&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="nv"&gt;ubuntu&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="nv"&gt;com&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;&lt;span class="w"&gt;

  &lt;/span&gt;&lt;span class="nv"&gt;include&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nv"&gt;etc&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nv"&gt;nginx&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nv"&gt;ip&lt;/span&gt;&lt;span class="o"&gt;_&lt;/span&gt;&lt;span class="nv"&gt;rules&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nv"&gt;ip&lt;/span&gt;&lt;span class="o"&gt;_&lt;/span&gt;&lt;span class="nv"&gt;block&lt;/span&gt;&lt;span class="o"&gt;_&lt;/span&gt;&lt;span class="nv"&gt;rules&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="nv"&gt;conf&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nv"&gt;deny&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;all&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;&lt;span class="w"&gt;

  &lt;/span&gt;&lt;span class="nv"&gt;location&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;

  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;




&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Which to Use:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Use &lt;code&gt;ngx_http_geo_module&lt;/code&gt;:&lt;/strong&gt; when you need granular control over access based on various criteria, require dynamic updates, or need to manage a large number of IP addresses efficiently.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Use &lt;code&gt;ngx_http_access_module&lt;/code&gt; directives&lt;/strong&gt;: when you have a simple use case of allowing or denying access to specific IP addresses or ranges and want a straightforward solution without the need for complex rules.&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;a href="https://github.com/misterfrenky/ngx_geo" rel="noopener noreferrer"&gt;GitHub Sample Repository 🐳&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Enjoy you practice 🌟 &lt;/p&gt;

</description>
      <category>nginx</category>
      <category>webhost</category>
      <category>infrastructure</category>
    </item>
  </channel>
</rss>
