Skip to content

Instantly share code, notes, and snippets.

@dunguyenn
dunguyenn / mongodb.txt
Created May 20, 2024 13:31 — forked from igoralves1/mongodb.txt
Install MongoDB on Ubuntu 18.04
- https://www.digitalocean.com/community/tutorials/how-to-install-mongodb-on-ubuntu-18-04
How to Install MongoDB on Ubuntu 18.04
Step 1 — Installing MongoDB
sudo apt update
sudo apt install -y mongodb
Step 2 — Checking the Service and Database
@dunguyenn
dunguyenn / ufw-script.sh
Created May 2, 2024 04:25 — forked from tskrynnyk/ufw-script.sh
Simple ufw script
#!/bin/sh
# ufw script
#
ufw disable
ufw --force reset
NET_PRIVATE_ADDR=(10.0.0.0/8 172.16.0.0/12 192.168.0.0/16)
for i in ${NET_PRIVATE_ADDR[@]}; do ufw allow from $i to any app 'SSH'; done
for i in ${NET_PRIVATE_ADDR[@]}; do ufw allow from $i to any app 'WWW Full'; done
@dunguyenn
dunguyenn / nginxproxy.md
Created December 6, 2023 07:23 — forked from soheilhy/nginxproxy.md
How to proxy web apps using nginx?

Virtual Hosts on nginx (CSC309)

When hosting our web applications, we often have one public IP address (i.e., an IP address visible to the outside world) using which we want to host multiple web apps. For example, one may wants to host three different web apps respectively for example1.com, example2.com, and example1.com/images on the same machine using a single IP address.

How can we do that? Well, the good news is Internet browsers

@dunguyenn
dunguyenn / block_china_ufw.sh
Created June 14, 2023 15:36 — forked from globian/block_china_ufw.sh
UFW blocks for China, Korea, Malaysia, Phillipines, Singapore, Thailand and Vietnam netblocks
#!/bin/sh
# UFW blocks for Asian countries except Japan
# Based on http://www.wizcrafts.net/chinese-iptables-blocklist.html
# https://www.ip2location.com/free/visitor-blocker
# Cambodia (KH)
ufw deny from 114.134.184.0/21
# Chinese (CN) IP addresses follow:
ufw deny from 1.68.0.0/14
ufw deny from 1.80.0.0/13
@dunguyenn
dunguyenn / block_china_ufw.sh
Created June 14, 2023 15:33 — forked from lewg/block_china_ufw.sh
UFW blocks for China, Korea, Malaysia, Phillipines, Singapore, Thailand and Vietnam netblocks
#!/bin/sh
# UFW blocks for China, Korea, Malaysia, Phillipines, Singapore, Thailand and Vietnam netblocks
# Based on http://www.wizcrafts.net/chinese-iptables-blocklist.html
# Cambodia (KH)
ufw deny from 114.134.184.0/21 to any port 22
# Chinese (CN) IP addresses follow:
ufw deny from 1.192.0.0/13 to any port 22
ufw deny from 1.202.0.0/15 to any port 22
@dunguyenn
dunguyenn / notes.md
Created December 13, 2022 03:41 — forked from Paprikas/notes.md
How to run multiple Redis instances on Ubuntu 18.04

Create the directory for the new instance

$ sudo install -o redis -g redis -d /var/lib/redis2

Create a new configuration file

$ sudo cp -p /etc/redis/redis.conf /etc/redis/redis2.conf
#!/bin/bash
###################################
# Usage: sudo ./installer.sh [os] #
###################################
OS=$1;
UBUNTU="ubuntu";
#############
@dunguyenn
dunguyenn / DigitalOcean.md
Created November 15, 2022 17:32 — forked from pilotpirxie/DigitalOcean.md
Node.js + Nginx + Redis + MySQL + PM2 configuration on DigitalOcean

Node.js + Nginx + Redis + MySQL + PM2 configuration on DigitalOcean

Installation

  1. Install LEMP stack
  2. Overwrite /etc/nginx/nginx.conf
# /etc/nginx/nginx.conf

user www-data;
@dunguyenn
dunguyenn / UFW.sh
Created October 13, 2021 17:40 — forked from rakibulinux/UFW.sh
How to Configure a Firewall with UFW
What is UFW?
UFW, or uncomplicated firewall, is a frontend for managing firewall rules in Arch Linux, Debian or Ubuntu. UFW is used through the command line (although it has GUIs available), and aims to make firewall configuration easy (or, uncomplicated).
sudo apt-get update && sudo apt-get upgrade
#Install UFW
sudo apt-get install ufw
#Use UFW to Manage Firewall Rules. Set Default Rules
sudo ufw default allow outgoing
@dunguyenn
dunguyenn / filter.d_nginx-auth.conf
Created October 10, 2020 06:24 — forked from JulienBlancher/filter.d_nginx-auth.conf
Fail2ban Config with Nginx and SSH
#
# Auth filter /etc/fail2ban/filter.d/nginx-auth.conf:
#
# Blocks IPs that makes too much accesses to the server
#
[Definition]
failregex = ^<HOST> -.*"(GET|POST).*HTTP.*"
ignoreregex =