Skip to content

Instantly share code, notes, and snippets.

View gilangvperdana's full-sized avatar
🎓
Still Learning

Gilang Virga Perdana gilangvperdana

🎓
Still Learning
View GitHub Profile
@gilangvperdana
gilangvperdana / nginx.conf
Created July 6, 2023 03:32
Dynamic Wildcard Server Name on Nginx Block
server {
listen 80;
server_name ~^([\w-]+)\.YOURDOMAIN\.com$;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl;
server_name ~^([\w-]+)\.YOURDOMAIN\.com$;
@gilangvperdana
gilangvperdana / manifests.yaml
Created July 3, 2023 11:22 — forked from alexeldeib/manifests.yaml
CRICTL IMAGE CLEANUP on K8S
apiVersion: v1
kind: ConfigMap
metadata:
name: imagecleanupconfig
namespace: default
labels:
component: imagecleanup
data:
# removes all images unused by a running container
cronjobs: 0 0 * * * crictl rmi --prune 2>&1
@gilangvperdana
gilangvperdana / README.md
Created July 2, 2023 16:22
SSH Session Exporter

General

Version 1: Docker Run

docker run -d -p 999:9999 -v /run/utmp:/run/utmp flor0/prometheus-ssh-exporter
@gilangvperdana
gilangvperdana / README.md
Last active March 18, 2024 18:57
Fail2ban on Ubuntu Server 20.04

General

Protect your Ubuntu Server with Fail2ban

Installation

apt install -y fail2ban

Check Status Ban

  • Default jail name is sshd
@gilangvperdana
gilangvperdana / README.md
Last active July 1, 2023 18:06
Install GeoIP for Nginx

General

  • If you want to see your client website region, you can install GeoIP module on Nginx
  • The project I've worked on, using (Filebeat, Logstash, Elasticsearch) after GeoIP is installed then visualized using Kibana or Grafana : image

Installation

sudo apt update
sudo apt install libnginx-mod-http-geoip
@gilangvperdana
gilangvperdana / docker-compose.yml
Last active June 28, 2023 13:26
CHR Dockerize
version: "3"
services:
routeros-6-47:
image: evilfreelancer/docker-routeros:latest
restart: unless-stopped
cap_add:
- NET_ADMIN
devices:
- /dev/net/tun
@gilangvperdana
gilangvperdana / README.md
Created June 28, 2023 12:18
Generate Certificate for Mikrotik

Generate Certificate for Mikrotik

openssl genrsa -des3 -out ca.key 4096
openssl req -new -x509 -days 3650 -key ca.key -out ca.crt
openssl genrsa -des3 -out server.key 4096
openssl req -new -key server.key -out server.csr
openssl x509 -req -days 3650 -in server.csr -CA ca.crt -CAkey ca.key -set_serial 01 -out server.crt
openssl genrsa -des3 -out client.key 4096
openssl req -new -key client.key -out client.csr
openssl x509 -req -days 3650 -in client.csr -CA ca.crt -CAkey ca.key -set_serial 01 -out client.crt

How to add an image to a gist

  1. Create a gist if you haven't already.
  2. Clone your gist:
    # make sure to replace `<hash>` with your gist's hash
    git clone https://gist.github.com/<hash>.git # with https
    git clone git@gist.github.com:<hash>.git     # or with ssh
@gilangvperdana
gilangvperdana / README.md
Created June 18, 2023 02:29
Force Reboot Ubuntu Server from CLI

Force Reboot Ubuntu from CLI

If you have a problem when you can't reboot or shutdown your VM with shutdown -r now reboot now etc, you can force reboot with this command :

sudo -i
echo s > /proc/sysrq-trigger
echo u > /proc/sysrq-trigger
echo b > /proc/sysrq-trigger
@gilangvperdana
gilangvperdana / harbor.sh
Created June 15, 2023 02:23 — forked from kacole2/harbor.sh
Quick Start Harbor Installation Script on Ubuntu 18.04
#!/bin/bash
#Harbor on Ubuntu 18.04
#Prompt for the user to ask if the install should use the IP Address or Fully Qualified Domain Name of the Harbor Server
PS3='Would you like to install Harbor based on IP or FQDN? '
select option in IP FQDN
do
case $option in
IP)