# number of requests client can make over keep-alive — for testing environment
keepalive_requests 100000;
}
Simpan kode diatas lalu jalankan perintah dibawah ini.
<code class="EnlighterJSRAW" data-enlighter-language="generic">nginx -s reload</code>
/etc/init.d/nginx start|restart
Jika ingin menguji konfigurasi, silahkan jalankan perintah berikut :
nginx -t
/etc/init.d/nginx configtest
Jika ingin aman maka ketik perintah berikut
server_tokens off;
Hal ini jauh dari pertahanan DDoS yang aman tetapi dapat memperlambat beberapa DDoS kecil. Konfigurasi tersebut juga dalam lingkungan pengujian dan Anda harus melakukan penilaian sendiri.
# limit the number of connections per single IP
limit_conn_zone $binary_remote_addr zone=conn_limit_per_ip:10m;
# limit the number of requests for a given session
limit_req_zone $binary_remote_addr zone=req_limit_per_ip:10m rate=5r/s;
# zone which we want to limit by upper values, we want limit whole server
server {
limit_conn conn_limit_per_ip 10;
limit_req zone=req_limit_per_ip burst=10 nodelay;
}
# if the request body size is more than the buffer size, then the entire (or partial)
# request body is written into a temporary file
client_body_buffer_size 128k;
# buffer size for reading client request header -- for testing environment
client_header_buffer_size 3m;
# maximum number and size of buffers for large headers to read from client request
large_client_header_buffers 4 256k;
# read timeout for the request body from client -- for testing environment
client_body_timeout 3m;
# how long to wait for the client to send a request header -- for testing environment
client_header_timeout 3m;
Selanjutnya lakukan pengujian konfigurasi lagi.
nginx -t # /etc/init.d/nginx configtest
Setelah selesai lakukan restart pada nginx
nginx -s reload
/etc/init.d/nginx reload|restart
Selanjutnya lakukan pengujian konfigurasi dengan tsung dan jika hasilnya sudah sesuai, tekan tombol Ctrl+C pada keyboard agar dapat berjalan selama berjam-jam.
Dua cara untuk menaikkan batas nofile/max open files/file descriptors/file handles untuk NGINX di RHEL/CentOS 7+. NGINX yang berjalan, dan memeriksa batas saat ini pada proses master.
$ cat /proc/$(cat /var/run/nginx.pid)/limits | grep open.files Max open files 1024 4096 files
Dan proses kerjanya
ps --ppid $(cat /var/run/nginx.pid) -o %p|sed '1d'|xargs -I{} cat /proc/{}/limits|grep open.files Max open files 1024 4096 files Max open files 1024 4096 files
Lalu silahkan coba
worker_rlimit_nofile directive in {,/usr/local}/etc/nginx/nginx.conf fails as SELinux policy doesn't allow setrlimit. This is shown in /var/log/nginx/error.log
015/07/24 12:46:40 [alert] 12066#0: setrlimit(RLIMIT_NOFILE, 2342) failed (13: Permission denied)
dan dalam file /var/log/audit/audit.log
type=AVC msg=audit(1437731200.211:366): avc: denied { setrlimit } for pid=12066 comm="nginx" scontext=system_u:system_r:httpd_t:s0 tcontext=system_u:system_r:httpd_t:s0 tclass=process
nolimit tanpa menggunakan sistem
# /etc/security/limits.conf # /etc/default/nginx (ULIMIT) $ nano /etc/security/limits.d/nginx.conf nginx soft nofile 65536 nginx hard nofile 65536 $ sysctl -p
nolimit dengan menggunakan sistem
$ mkdir -p /etc/systemd/system/nginx.service.d $ nano /etc/systemd/system/nginx.service.d/nginx.conf [Service] LimitNOFILE=30000 $ systemctl daemon-reload $ systemctl restart nginx.service
httpd_setrlimit
to true(1)Penetapan batas fd dalam proses kerja
worker_rlimit_nofile directive in {,/usr/local}/etc/nginx/nginx.conf
Dan jalankan menggunakan root dengan perintah berikut :
setsebool -P httpd_setrlimit 1
Secara default max_ranges tidak dibatasi. Serangan DoS bisa dari banyak Range-Requests (Dampak pada stabilitas I/O).
Socket type | Latency (ms) | Latency stdev (ms) | CPU Load |
---|---|---|---|
Default | 15.65 | 26.59 | 0.3 |
accept_mutex off | 15.59 | 26.48 | 10 |
reuseport | 12.35 | 3.15 | 0.3 |
Pengiriman file multi-utas saat ini hanya didukung oleh sistem operasi Linux. Tanpa batas sendfile_max_chunk, satu koneksi yang cepat dan dapat menyita seluruh proses pekerja.
map $ssl_preread_protocol $upstream { "" ssh.example.com:22; "TLSv1.2" new.example.com:443; default tls.example.com:443; } # ssh and https on the same port server { listen 192.168.0.1:443; proxy_pass $upstream; ssl_preread on; }
Selesai selamat mencoba.
Semoga artikel ini membantu anda lebih memahami Nginx. Jangan sungkan tinggalkan komentar di bawah jika anda memiliki pertanyaan. Sampai jumpa di artikel selanjutnya.
Page: 1 2
Pengenalan: Server STB (Set-Top Box) adalah perangkat yang digunakan untuk mengelola konten dan layanan televisi…
Sebelum memulai, penting untuk diketahui bahwa mengakses internet gratis dengan menggunakan VPN bukanlah praktik yang…
Sebelum memulai tutorial ini, pastikan bahwa STB Anda telah membuka akses root, karena Anda membutuhkan…
Set top box (STB) dengan sistem operasi openwrt semakin populer di Indonesia. Hal ini karena…
Server STB – Mengenal Deface Website Pengertian Deface Website Deface Web adalah serangan terhadap situb…