Cara Install Nginx Sebagai Reverse Proxy Apache

<p><strong>Cara Install Nginx Sebagai Reverse Proxy Apache &&num;8211&semi;<&sol;strong> Ada beberapa alasan mengapa kita menginstall 2 web server sekaligus dalam 1 VPS&period; Alasan popularitas apache dan nginx sudah jelas&period; Apache terkenal dengan kekuatannya sedangkan nginx terkenal akan kecepatannya&period; Akan tetapi apache web server sangat boros akan memory server&comma; sedangkan Nginx bagus untuk web statis dan membutuhkan modul php-fpm untuk mengelola konten yang dinamis&comma; seperti wordpress dsb&period;<br &sol;>&NewLine;Namun&comma; kita dapat menggabungkan 2 webserver pada satu vps yang mana nantinya Nginx sebagai front end &lpar;sebagai web server statis&rpar; sedangkan Apache sebagai back end &lpar;pemroses&rpar;&period;<&sol;p>&NewLine;<p>Meskipun ada yang berpendapat bahwa menginstall 2 web server sekaligus justru malah akan memakan resource VPS 2 kali lipat&period; Tapi tidak ada salahnya kita mencoba hal tersebut agar kita tahu lebih jelas perbedaannya&period;<&sol;p>&NewLine;<h2><strong>Cara Install Nginx Sebagai Reverse Proxy Apache<&sol;strong><&sol;h2>&NewLine;<h3><strong>Install Nginx<&sol;strong><&sol;h3>&NewLine;<pre class&equals;"lang&colon;sh decode&colon;true">apt-get update &NewLine;apt-get install nginx<&sol;pre>&NewLine;<h3><strong>Konfigurasi Nginx virtual Host<&sol;strong><&sol;h3>&NewLine;<p>buat konfigurasi dengan nama example&comma; bisa disesuaikan dengan keinginan anda&period;<&sol;p>&NewLine;<pre class&equals;"lang&colon;default decode&colon;true ">nano &sol;etc&sol;nginx&sol;sites-available&sol;example<&sol;pre>&NewLine;<p>Copy paste konfigurasi dibawah ini&period; konfig ini hampir sama dengan default konfig nginx&period; bedanya kita akan memforward proxy header ke apache &lpar;backend&rpar;&period;<&sol;p>&NewLine;<pre class&equals;"lang&colon;default decode&colon;true ">server &lbrace; &NewLine; listen 80&semi; &NewLine; &NewLine; root &sol;var&sol;www&sol;&semi; &NewLine; index index&period;php index&period;html index&period;htm&semi; &NewLine; &NewLine; server&lowbar;name example&period;com&semi; &NewLine; &NewLine; location &sol; &lbrace; &NewLine; try&lowbar;files &dollar;uri &dollar;uri&sol; &sol;index&period;php&semi; &NewLine; &rcub; &NewLine; &NewLine; location ~ &bsol;&period;php&dollar; &lbrace; &NewLine; &NewLine; proxy&lowbar;set&lowbar;header X-Real-IP &dollar;remote&lowbar;addr&semi; &NewLine; proxy&lowbar;set&lowbar;header X-Forwarded-For &dollar;remote&lowbar;addr&semi; &NewLine; proxy&lowbar;set&lowbar;header Host &dollar;host&semi; &NewLine; proxy&lowbar;pass http&colon;&sol;&sol;127&period;0&period;0&period;1&colon;8080&semi; &NewLine; &NewLine; &rcub; &NewLine; &NewLine; location ~ &sol;&bsol;&period;ht &lbrace; &NewLine; deny all&semi; &NewLine; &rcub; &NewLine;&rcub;<&sol;pre>&NewLine;<h3><strong>Mengaktifkan Virtual Host Nginx<&sol;strong><&sol;h3>&NewLine;<pre class&equals;"lang&colon;default decode&colon;true ">ln -s &sol;etc&sol;nginx&sol;sites-available&sol;example &sol;etc&sol;nginx&sol;sites-enabled&sol;example<&sol;pre>&NewLine;<h3><strong>hapus default nginx server block<&sol;strong><&sol;h3>&NewLine;<pre class&equals;"lang&colon;default decode&colon;true ">rm &sol;etc&sol;nginx&sol;sites-enabled&sol;default<&sol;pre>&NewLine;<p>Installasi nginx cukup seperti ini saja&period; Sekarang kita tinggal menginstall apache web server yang nantinya di gunakan sebagai backend dari nginx&period;<&sol;p>&NewLine;<p>&nbsp&semi;<&sol;p>&NewLine;<h3>Install Apache<&sol;h3>&NewLine;<pre class&equals;"lang&colon;default decode&colon;true ">apt-get install apache2<&sol;pre>&NewLine;<h3>Konfigurasi Apache<&sol;h3>&NewLine;<pre class&equals;"lang&colon;default decode&colon;true ">nano &sol;etc&sol;apache2&sol;ports&period;conf<&sol;pre>&NewLine;<p>Cari dan ubah konfigurasi apache menjadi seperti dibawah ini&period;<&sol;p>&NewLine;<pre class&equals;"lang&colon;default decode&colon;true ">NameVirtualHost 127&period;0&period;0&period;1&colon;8080 &NewLine;Listen 127&period;0&period;0&period;1&colon;8080<&sol;pre>&NewLine;<p>Simpan&period;<&sol;p>&NewLine;<h3><strong>Konfigurasi Apache2 Virtual Host<&sol;strong><&sol;h3>&NewLine;<p>Copy saja dari konfigurasi default menjadi example&period;<&sol;p>&NewLine;<pre class&equals;"lang&colon;default decode&colon;true">cp &sol;etc&sol;apache2&sol;sites-available&sol;default &sol;etc&sol;apache2&sol;sites-available&sol;example<&sol;pre>&NewLine;<p>Buka konfigurasi dengan nama example tadi&period;<&sol;p>&NewLine;<pre class&equals;"lang&colon;default decode&colon;true ">nano &sol;etc&sol;apache2&sol;sites-available&sol;example<&sol;pre>&NewLine;<p>Ubah juga virtual host seperti  pada konfigurasi nginx tadi dengan port 8080&period; seperti dibawah ini&period;<&sol;p>&NewLine;<pre class&equals;"lang&colon;default decode&colon;true ">&lt&semi;VirtualHost 127&period;0&period;0&period;1&colon;8080&gt&semi;<&sol;pre>&NewLine;<p><strong>Aktifkan Virtual Host Apache2<&sol;strong><&sol;p>&NewLine;<pre class&equals;"lang&colon;default decode&colon;true">a2ensite example<&sol;pre>&NewLine;<p>Sebelum melakukan testing&period; kita perlu menginstall php&period;<&sol;p>&NewLine;<pre class&equals;"lang&colon;default decode&colon;true ">apt-get install php5<&sol;pre>&NewLine;<p>Restart kedua web server&period;<&sol;p>&NewLine;<pre class&equals;"lang&colon;default decode&colon;true">service apache2 restart &amp&semi;&amp&semi; service nginx restart<&sol;pre>&NewLine;<h3><strong>Finishing&period;<&sol;strong><&sol;h3>&NewLine;<p>Cek info php&period;<&sol;p>&NewLine;<pre class&equals;"lang&colon;default decode&colon;true ">nano &sol;var&sol;www&sol;info&period;php<&sol;pre>&NewLine;<p>masukkan perintah dibawah ini&period;<&sol;p>&NewLine;<pre class&equals;"lang&colon;default decode&colon;true ">&lt&semi;&quest; &NewLine;phpinfo&lpar; &rpar;&semi; &NewLine;&quest;&gt&semi;<&sol;pre>&NewLine;<p>lalu buka http&colon;&sol;&sol;ipaddress&sol;info&period;php &comma;maka akan tampil info lengkap tentang php yang digunakan&period; &lpar;Lihat Gambar&rpar;&period;<&sol;p>&NewLine;<p>Lihat pada bagian <strong>Server API&comma; <&sol;strong>jika kita melakukan installasi nginx dan apache sebagai reverse proxy dengan benar maka ia tetap menggunakan apache sebagai pemroses&period;<&sol;p>&NewLine;<p><a href&equals;"https&colon;&sol;&sol;www&period;tutorialpedia&period;net&sol;wp-content&sol;uploads&sol;2016&sol;11&sol;TyotN&period;png"><img class&equals;"aligncenter size-large wp-image-2505" src&equals;"https&colon;&sol;&sol;www&period;tutorialpedia&period;net&sol;wp-content&sol;uploads&sol;2016&sol;11&sol;TyotN-1024x601&period;png" alt&equals;"cara install nginx" width&equals;"900" height&equals;"528" &sol;><&sol;a><&sol;p>&NewLine;<p>Perbedaan ketika anda menggunakan nginx saja adalah pada server API ia menggunakan modul php-fpm sebagai pemroses untuk konten dinamisnya&period;<&sol;p>&NewLine;<p><a href&equals;"https&colon;&sol;&sol;www&period;tutorialpedia&period;net&sol;wp-content&sol;uploads&sol;2016&sol;11&sol;Screenshot8&period;png"><img class&equals;"aligncenter size-full wp-image-2506" src&equals;"https&colon;&sol;&sol;www&period;tutorialpedia&period;net&sol;wp-content&sol;uploads&sol;2016&sol;11&sol;Screenshot8&period;png" alt&equals;"cara install nginx" width&equals;"609" height&equals;"564" &sol;><&sol;a><&sol;p>&NewLine;<p>Jadi hasil akhir dari tutorial ini adalah kita menginstall nginx pada port <strong>80<&sol;strong> ketika ada request maka nginx akan mem-forward request tersebut ke apache yang mana apache ini berjalan pada port <strong>8080<&sol;strong>&period;<&sol;p>&NewLine;<p>Anda bisa mengecek port yang berjalan pada vps anda menggunakan perintah berikut&colon;<&sol;p>&NewLine;<pre class&equals;"lang&colon;default decode&colon;true ">netstat -ntulp<&sol;pre>&NewLine;<p>Demikian Cara Install Nginx Sebagai Reverse Proxy Apache<&sol;p>&NewLine;

Recent Articles

Kumpulan DNS Gratis Tercepat!

0
DNS merupakan sebuah sistem yang bertugas menyimpan semua informasi data domain dalam jaringan. Dengan adanya DNS, domain atau hostname yang ada akan ditranslate dan...

Apa itu DNS ? Dan Fungsinya

0
Apa itu DNS? - DNS (Domain Name System) adalah sebuah sistem yang bertugas menyimpan semua informasi data domain dalam jaringan. Dengan adanya DNS, domain...

Apa itu OLT ? Serta Fungsinya Dalam Jaringan

0
Apa itu olt ? OLT (Optical Line Termination) adalah perangkat keras yang berfungsi sebagai titik akhir (end-point) dari layanan jaringan optik pasif (Passive Optical...

Template Voucher Untuk Mixradius

2
Template Voucher Untuk Mixradius - Pasti kalian bosen kan dengan template voucher default mixradius? tenang. kali ini saya akan memberikan template untuk voucher mixradius kamu agar...

Daftar Port Game Online Mikrotik Terbaru

2
Daftar port game online dibawah ini bisa digunakan untuk membuat rule agar koneksi ke game online tersebut bisa lancar, bisa juga untuk memisahkan antara...

Related Articles

Leave A Reply

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Dapatkan konten terbaik dari kami!