andriajah Fri Aug 2022 1 year ago

Cara Allow Access IP Address di Apache Ubuntu

Izinkan akses berdasarkan alamat IP di Apache ubuntu; Melalui tutorial ini, kita akan mempelajari cara mengakses allow by IP address di server apache ubuntu 21.10, ubuntu 21.04, ubuntu 20.04, ubuntu 18.04 dan ubuntu 16.04.

Cara Allow Access dengan Alamat IP di Apache Ubuntu

Gunakan langkah-langkah berikut untuk mengakses izinkan dengan alamat IP di server Apache ubuntu; sebagai berikut:

  • Buka 000- File .conf default
  • Perbarui 000- File .conf default
  • Mulai ulang Server Web Apache
  • Uji dengan Alamat IP

Buka 000- File .conf default

Buka terminal Anda dan jalankan perintah berikut di terminal untuk membuka file 000-default.conf; sebagai berikut:

sudo nano /etc/Apache2/sites-available/000-default.conf

Perbarui 000- File .conf default

Kemudian tambahkan tag Direktori untuk mengizinkan akses berdasarkan alamat IP. kami menambahkan “111.111.111.111”, Anda dapat mengganti yang mana jika Anda ingin memblokir; sebagai berikut:

<VirtualHost *:80>
  # The ServerName directive sets the request scheme, hostname and port that
  # the server uses to identify itself. This is used when creating
  # redirection URLs. In the context of virtual hosts, the ServerName
  # specifies what hostname must appear in the request's Host: header to
  # match this virtual host. For the default virtual host (this file) this
  # value is not decisive as it is used as a last resort host regardless.
  # However, you must set it for any further virtual host explicitly.
  #ServerName www.example.com
   
  ServerAdmin webmaster@localhost
  DocumentRoot /var/www/html
   
  # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
  # error, crit, alert, emerg.
  # It is also possible to configure the loglevel for particular
  # modules, e.g.
  #LogLevel info ssl:warn
   
  ErrorLog ${APACHE_LOG_DIR}/error.log
  CustomLog ${APACHE_LOG_DIR}/access.log combined
   
  # For most configuration files from conf-available/, which are
  # enabled or disabled at a global level, it is possible to
  # include a line for only one particular virtual host. For example the
  # following line enables the CGI configuration for this host only
  # after it has been globally disabled with "a2disconf".
  #Include conf-available/serve-cgi-bin.conf
   
  <Directory /var/www/html>
      Order deny,allow
      deny from all
      Allow from 111.111.111.111
  </Directory>
          
</VirtualHost>

Mulai ulang Server Web Apache

Jalankan perintah berikut di terminal untuk me-restart server web apache; sebagai berikut:

sudo service apache2 reload

Uji dengan Alamat IP

Buka browser dan periksa IP Anda; sebagai berikut:

http://your_server_ip 

ATAU 

http://localhost

 

apache allow access ip address example