Nginx:Install ModSecurity: Difference between revisions
No edit summary |
No edit summary |
||
| Line 116: | Line 116: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
*Tambahkan code berikut | *Tambahkan code berikut | ||
<syntaxhighlight lang="nginx"> | <syntaxhighlight lang="nginx"> | ||
load_module /etc/nginx/modules/ngx_http_modsecurity_module.so; | load_module /etc/nginx/modules/ngx_http_modsecurity_module.so; | ||
</syntaxhighlight> | </syntaxhighlight> | ||
*'''Sample''' | *'''Sample''' | ||
<syntaxhighlight lang="nginx"> | |||
<syntaxhighlight lang="nginx" line="1"> | |||
user www-data; | user www-data; | ||
worker_processes auto; pid /run/nginx.pid; | worker_processes auto; pid /run/nginx.pid; | ||
| Line 131: | Line 134: | ||
*Pertama, hapus kumpulan aturan saat ini bawaan sebelumnya dengan ModSecurity, menggunakan perintah berikut: | *Pertama, hapus kumpulan aturan saat ini bawaan sebelumnya dengan ModSecurity, menggunakan perintah berikut: | ||
<syntaxhighlight lang="shell"> | |||
sudo rm -rf /usr/share/modsecurity-crs | |||
</syntaxhighlight> | |||
*Clone repository ke directory <code>/usr/local/modsecurity-crs</code> | *Clone repository ke directory <code>/usr/local/modsecurity-crs</code> | ||
<syntaxhighlight lang="shell"> | |||
sudo git clone https://github.com/coreruleset/coreruleset /usr/local/modsecurity-crs | |||
</syntaxhighlight> | |||
*Rename the <code>crs-setup.conf.example</code> ke <code>crs-setup.conf</code>: | *Rename the <code>crs-setup.conf.example</code> ke <code>crs-setup.conf</code>: | ||
<syntaxhighlight lang="shell"> | |||
sudo mv /usr/local/modsecurity-crs/crs-setup.conf.example /usr/local/modsecurity-crs/crs-setup.conf | |||
</syntaxhighlight> | |||
*Ganti nama file aturan pengecualian permintaan default: | *Ganti nama file aturan pengecualian permintaan default: | ||
<syntaxhighlight lang="shell"> | |||
sudo mv /usr/local/modsecurity-crs/rules/REQUEST-900-EXCLUSION-RULES-BEFORE-CRS.conf.example /usr/local/modsecurity-crs/rules/REQUEST-900-EXCLUSION-RULES-BEFORE-CRS.conf | |||
</syntaxhighlight> | |||
Sekarang harus menyiapkan OWASP-CRS dan siap digunakan dalam konfigurasi [[Nginx]]. | Sekarang harus menyiapkan OWASP-CRS dan siap digunakan dalam konfigurasi [[Nginx]]. | ||
| Line 146: | Line 160: | ||
==Konfigurasi ModSecurity== | ==Konfigurasi ModSecurity== | ||
*Mulailah dengan membuat direktori ModSecurity di direktori <code>/etc/nginx/</code>: | *Mulailah dengan membuat direktori ModSecurity di direktori <code>/etc/nginx/</code>: | ||
<syntaxhighlight lang="shell"> | |||
sudo mkdir -p /etc/nginx/modsec | |||
</syntaxhighlight> | |||
*Salin file pemetaan unicode dan file konfigurasi ModSecurity dari repository GitHub ModSecurity cloning kalian: | *Salin file pemetaan unicode dan file konfigurasi ModSecurity dari repository GitHub ModSecurity cloning kalian: | ||
<syntaxhighlight lang="shell"> | |||
sudo cp /opt/ModSecurity/unicode.mapping /etc/nginx/modsec | |||
</syntaxhighlight> | |||
<syntaxhighlight lang="shell">sudo cp /opt/ModSecurity/modsecurity.conf-recommended /etc/nginx/modsec/modsecurity.conf</syntaxhighlight> | |||
*Hapus ekstensi <code>.recommended</code> dari nama file konfigurasi ModSecurity dengan perintah berikut: | *Hapus ekstensi <code>.recommended</code> dari nama file konfigurasi ModSecurity dengan perintah berikut: | ||
<syntaxhighlight lang="shell"> | |||
sudo cp /etc/modsecurity/modsecurity.conf-recommended /etc/modsecurity/modsecurity.conf | |||
</syntaxhighlight> | |||
*Dengan editor teks seperti vim atau nano, buka <code>/etc/modsecurity/modsecurity.conf</code> dan ubah nilai untuk <code>SecRuleEngine</code> menjadi <code>On</code>: | *Dengan editor teks seperti vim atau nano, buka <code>/etc/modsecurity/modsecurity.conf</code> dan ubah nilai untuk <code>SecRuleEngine</code> menjadi <code>On</code>: | ||
<syntaxhighlight lang="shell" line="1"> | |||
# -- Rule engine initialization ---------------------------------------------- | |||
# Enable ModSecurity, attaching it to every transaction. Use detection | |||
# only to start with, because that minimises the chances of post-installation | |||
# disruption. | |||
# | |||
SecRuleEngine On | |||
</syntaxhighlight> | |||
*Buat file konfigurasi baru bernama <code>main.conf</code> di direktori <code>/etc/nginx/modsec</code>: | *Buat file konfigurasi baru bernama <code>main.conf</code> di direktori <code>/etc/nginx/modsec</code>: | ||