Saltar al contenido

How do I use .htaccess to block an IP address in Lightsail?

1 minutos de lectura
0

I want to use .htaccess rules in Amazon Lightsail to block an IP address from my Bitnami application.

Resolution

Locate the .htaccess file. Its default location for most applications is /opt/bitnami/apache/conf/vhosts/htaccess/your-application-htaccess.conf. For more information about .htaccess file locations, see Understand default .htaccess file configuration on the Bitnami website.

To block an IP address from your Bitnami application, complete the following steps:

  1. Edit the access configuration file:

    vi /opt/bitnami/apache2/conf/vhosts/wordpress-https-vhost.conf
  2. Change AllowOverride from None to All. If AllowOverride is already set to All, then proceed to step 3:

    ...  
    AllowOverride All  
    ...

    Note: Replace example-application with your application name.

  3. Edit the .htaccess file:

    sudo vi /opt/bitnami/apache/conf/vhosts/htaccess/example-application-htaccess.conf

    Note: Replace example-application with your application name.

  4. Create a rule to block the IP address:

    order deny,allow  
    deny from example-ip-address

    Note: Replace example-application with your application name and example-ip-address with the IP address that you want to block.

  5. Restart Apache:

    sudo /opt/bitnami/ctlscript.sh restart apache
  6. Verify Apache status:

    sudo /opt/bitnami/ctlscript.sh status apache
OFICIAL DE AWSActualizada hace 2 años