Postingan

Menampilkan postingan dengan label Apache2

📘 How to Send Apache + ModSecurity Logs to AWS CloudWatch Logs on EC2

In this guide, you'll learn how to forward ModSecurity logs from Apache to AWS CloudWatch Logs using the CloudWatch Agent on an EC2 instance with an IAM Role , and ensure it runs reliably using systemd . ✅ Prerequisites An EC2 instance (Ubuntu/Debian) Apache2 and ModSecurity installed Instance has an IAM Role attached with permission: CloudWatchAgentServerPolicy or: { "Effect": "Allow", "Action": [ "logs:CreateLogGroup", "logs:CreateLogStream", "logs:PutLogEvents", "logs:DescribeLogStreams" ], "Resource": "*" } ⚙️ Step 1: Install the CloudWatch Agent cd /opt curl -O https://s3.amazonaws.com/amazoncloudwatch-agent/ubuntu/amd64/latest/amazon-cloudwatch-agent.deb sudo dpkg -i amazon-cloudwatch-agent.deb 🛠️ Step 2: Create the Agent Configuration File Save this file as /opt/cloudwatch-config.json : { "logs": { "logs_colle...

How to configure apache2 auth openldap debian

Autentikasi Website Apache2 Menggunakan OpenLDAP Berikut adalah konfigurasi sederhana untuk melakukan autentikasi login website di Apache2 menggunakan LDAP (OpenLDAP) . 📌 Prasyarat Pastikan hal berikut sudah siap: Web server Apache2 sudah terinstall dan berjalan dengan baik. Tentukan site / direktori website yang akan dipasang autentikasi. Server sudah siap. Tutorial instalasi OpenLDAP, pembuatan user, dan testing login dapat dilihat pada video berikut: https://www.youtube.com/playlist?list=PL-p0E1DAGrw3cYSqmGUArs1qQSRPdbUmJ 1️⃣ Enable Modul LDAP di Apache2 Jalankan perintah berikut: a2enmod ldap authnz_ldap Modul yang diaktifkan: ldap → koneksi LDAP authnz_ldap → autentikasi & authorization LDAP 2️⃣ Buat Konfigurasi Autentikasi LDAP Buat file konfigurasi baru: vi /etc/apache2/sites-available/auth-ldap.conf Isi dengan konfigurasi berikut: <Directory /var/www/html/> AuthName "LDAP Authentication" AuthType Basic AuthBasicPro...

Configure Reverse Proxy With Apache2 on Debian 9

Load modules #a2enmod proxy #a2enmod proxy_http Virtualhost Configuration #cd /etc/apache2/sites-available/ #vi myproxyweb <VirtualHost *:80>         ServerName mywebsite.id         ProxyPass       /       http://192.168.1.1:8080/         ProxyPassReverse   /    http://192.168.1.1:8080/ </VirtualHost> Disable Default #a2dissite default Enable new Virtualhost #a2ensite myproxyweb Restart Apache #systemctl restart apache2 OK!

Virtual host berjalan di port 8080 menggunakan software apache2 dengan OS: Centos7

Soal: Buatlah sebuah virtual host berjalan di port 8080 menggunakan software apache2 dengan OS: Centos7, buat file index.html, dan simpan log access dan error di /var/log/httpd/dashboard2 Jawab: #yum install httpd Tambah script Listen8080 dibawah Listen80 di file berikut #vi /etc/httpd/conf/httpd.conf Listen80 Listen8080 #cd /var/www/html #mkdir dashboard2 #chown apache.apache dashboard2 -R #cd dashboard2 #mkdir public #echo "Welcome to Dashboard2" > public/index.html #mkdir /var/log/httpd/dashboard2 #vi /etc/httpd/conf.d/dashboard2.conf <VirtualHost *:8080> ServerAdmin webmaster@sysops.com ServerName 107.102.182.128:8080 DocumentRoot /var/www/html/dashboard2/public/ ErrorLog /var/log/httpd/dashboard2/error.log CustomLog /var/log/httpd/dashboard2/access.log combined </VirtualHost> #systemctl restart httpd

Cara redirect IP ke domain, non-www ke www dengan htaccess di apache2

Redirect IP ke Domain Menggunakan .htaccess di Apache2 Berikut adalah cara sederhana untuk melakukan redirect akses via IP ke nama domain menggunakan file .htaccess . Dengan konfigurasi ini, ketika user membuka website menggunakan IP server, browser akan otomatis diarahkan ke domain, dan address bar juga berubah menjadi nama domain. Metode ini umum digunakan pada web server Apache2. 🧭 Tujuan Konfigurasi Misalnya: User akses → http://192.168.81.128 Maka otomatis akan diarahkan ke: http://www.nusantara.cloud ⚙️ Langkah Konfigurasi 1️⃣ Aktifkan Module Rewrite Jalankan perintah berikut: a2enmod rewrite systemctl restart apache2 2️⃣ Pastikan Virtual Host Mengizinkan .htaccess Edit file virtual host, misalnya: /etc/apache2/sites-available/000-default.conf Pastikan bagian directory seperti berikut: <Directory /var/www/html/nusantara/> Options Indexes FollowSymLinks AllowOverride All Require all granted </Directory> 📌 Penting: AllowOverride All...