Server STB
Menu
  • Beranda
  • Layanan
    • JASA
    • Aplikasi
    • Sistem Operasi
  • Harga
  • Wiki
  • Blog
  • Teknologi
    • Server
    • Unduh
  • Kontak
  • Login
  • member
Menu
nginx & apache

Cara Install Nginx + SSL Sebagai Reverse Proxy untuk Apache di STB

Posted on 8 June 202218 June 2022 by admin

Cara install Nginx + SSL Sebagai Reverse Proxy untuk Apache di STB (Set Top Box)

Server STB – Nginx dan Apache dapat digunakan secara bersamaan dimana Nginx bertindak sebagai reverse proxy yang menerima permintaan dari client dan meneruskannya ke web server lain seperti Apache, kemudian Apache mengirimkan kembali respon yang diminta oleh Nginx untuk dikirimkan ke client. Hal ini dilakukan agar kedua web server ini bisa saling menutupi kekurangan.

Nginx sebagai Reverse Proxy untuk Apache
Nginx sebagai Reverse Proxy untuk Apache

1. Install Apache

apt update
apt

install apache2 php-fpm -y

Install FastCGI module

wget https://mirrors.edge.kernel.org/ubuntu/pool/multiverse/liba/libapache-mod-fastcgi/libapache2-mod-fastcgi_2.4.7~0910052141-1.2_amd64.deb

dpkg -i libapache2-mod-fastcgi_2.4.7~0910052141-1.2_amd64.deb

2. Setting Apache

Rubah terlebih dahulu nama file konfigurasi Apache port.conf
mv /etc/apache2/ports.conf /etc/apache2/ports.conf.default

Lanjutkan untuk membuat file baru port.conf dengan nomor port 8080

echo "Listen 8080" | tee /etc/apache2/ports.conf

Nonaktifkan Apache virtual host 000-default

a2dissite 000-default

Buatlah file konfigurasi virtual host

vim /etc/apache2/sites-available/001-default.conf

Masukkan konfigurasi 001-default.conf

 

<VirtualHost *:8080>
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Selanjutnya aktifkan virtual host 001-default.conf
a2ensite 001-default

Setelah selesai lalu lakukan Restart Apache

systemctl restart apache2

Selanjutnya verifikasi apakah Apache sudah berjalan di port 8080

netstat -tulpn

Hasilnya akan terlihat bahwa apache2 berjalan di port 8080

Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 127.0.0.53:53           0.0.0.0:*               LISTEN      870/systemd-resolve 
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      1065/sshd           
tcp6       0      0 :::8080                 :::*                    LISTEN      8774/apache2        
tcp6       0      0 :::22                   :::*                    LISTEN      1065/sshd

3. Setting Apache untuk menggunakan mod_fastcgi

Aktifkan terlebih dahulu actions module

a2enmod actions

Lalu rubahlah nama file konfigurasi FastCGI

mv /etc/apache2/mods-enabled/fastcgi.conf /etc/apache2/mods-enabled/fastcgi.conf.default

Setelah itu buat file konfigurasi baru untuk FastCGI

vim /etc/apache2/mods-enabled/fastcgi.conf

Masukkan konfigurasi FastCGI

<IfModule mod_fastcgi.c>
  AddHandler fastcgi-script .fcgi
  FastCgiIpcDir /var/lib/apache2/fastcgi
  AddType application/x-httpd-fastphp .php
  Action application/x-httpd-fastphp /php-fcgi
  Alias /php-fcgi /usr/lib/cgi-bin/php-fcgi
  FastCgiExternalServer /usr/lib/cgi-bin/php-fcgi -socket /run/php/php7.2-fpm.sock -pass-header Authorization
  <Directory /usr/lib/cgi-bin>
    Require all granted
  </Directory>
</IfModule>

Tes konfigurasi Apache

apachectl -t

Hasilnya Syntax OK, restart Apache

systemctl restart apache2

4.Verifikasi PHP

Lakukan verifikasi apakah script PHP sudah bisa dijalankan oleh Apache web server, berikut langkahnya :

Membuat file info.php untuk memanggil fungsi phpinfo

echo "<?php phpinfo(); ?>" | tee /var/www/html/info.php

Browse http://IP_SERVER:8080/info.php, cek Server API, SERVER_PORT, dan SERVER_SOFTWARE.

PHP Information – Server API
PHP Information – Server API
PHP Information – SERVER PORT dan SERVER SOFTWARE
PHP Information – SERVER PORT dan SERVER SOFTWARE

5.Membuat Apache Virtual Host

Membuat konfigurasi Apache virtual host untuk subdomain web.defnex.com.
yang pertama membuat folder document root

mkdir /var/www/web.defnex.com

lalu membuat file index.html

echo "<h1>web.defnex.com</h1>" | tee /var/www/web.defnex.com/index.html

dan buatlah file info.php

echo "<?php phpinfo(); ?>" | tee /var/www/web.defnex.com/info.php

Selanjutnya buat file virtual host untuk web.defnex.com

vim /etc/apache2/sites-available/web.defnex.com.conf

Stelah itu masukkan konfigurasi virtual host

<VirtualHost *:8080>
    ServerName web.defnex.com
    DocumentRoot /var/www/web.defnex.com
    <Directory /var/www/web.defnex.com>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Require all granted
    </Directory>
    ErrorLog /var/log/apache2/web.defnex.com_error.log
    CustomLog /var/log/apache2/web.defnex.com_access.log combined
</VirtualHost>

Lalu aktifkan virtual host

a2ensite web.defnex.com

Setelah selesai cek konfigurasi Apache

apachectl -t

dan lakukan restart Apache

systemctl restart apache2

Lalu verifikasi konfigurasi virtual host apakah sudah berfungsi dengan baik, browse http://web.defnex.com:8080

Browse subdomain
Browse subdomain

6.Install dan Setting Nginx

Install Nginx
apt install nginx -y

Kemudian buatlah konfigurasi Nginx server block untuk web.defnex.com
vim /etc/nginx/conf.d/web.defnex.com.conf

Kemudian Memasukkan konfigurasi server block

server {
listen 80;
server_name web.defnex.com;
root /var/www/web.defnex.com;
index index.php index.htm index.html;

location / {
try_files $uri $uri/ /index.php?$query_string;
}

location ~ \.php$ {
proxy_pass http://178.128.212.251:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}

Loading

Pages: 1 2
Category: Aplikasi, Server

Riwayat Pos

  • Mengoptimalkan Kecerdasan Buatan dengan n8n: Otomasi dan Integrasi Tanpa Coding
  • Perbedaan CBT dan CAT: Kenali Metode Ujian Digital yang Semakin Populer
  • AI dan Manusia: Kolaborasi Menuju Masa Depan
  • Cara Mengubah Ukuran Partisi Root dan Memperbesar LVM di Ubuntu 20.04
  • Cara Mencari File dengan Perintah find di Linux

Katagori

  • Aplikasi (9)
  • Berita (2)
  • Database (1)
  • Member (9)
  • Server (10)
  • Sistem Operasi (4)
  • STB (15)
    • Server STB (6)
  • Teknologi (8)
  • Unduh (2)

Server STB

  • Daftar
  • Cari
  • Media
  • Cloud
  • Openwrt
  • Wiki

Tags

apache Database docker firewall internet iot keamanan Load Balance nginx prmox review ubuntu

Iklan

Everyday Local Server

apache Database docker firewall internet iot keamanan Load Balance nginx prmox review ubuntu

WhatsApp : +6289677814176
Email : [email protected]
© 2025 Server STB | Powered by Minimalist Blog WordPress Theme