apache2/httpd – IP based restriction to a virtual host

The Require provides a variety of different ways to allow or deny access to resources. In conjunction with the RequireAll, RequireAny, and RequireNone directives, these requirements may be combined in arbitrarily complex ways, to enforce whatever your access policy happens to be.

example:

<VirtualHost *:80>

ServerName example.net
Documentroot /var/www/html/

<Location 
Read more

linux swap memory limits – reference guide

Table 1: Recommended system swap space in Fedora 28 documentation

Amount of system RAMRecommended swap spaceRecommended swap with hibernation
less than 2 GB2 times the amount of RAM3 times the amount of RAM
2 GB – 8 GBEqual to the amount of RAM2 times
Read more

adminer setup script

Adminer (formerly phpMinAdmin) is a full-featured database management tool written in PHP. Conversely to phpMyAdmin, it consists of a single file ready to deploy to the target server. Adminer is available for MySQL, MariaDB, PostgreSQL, SQLite, MS SQL, Oracle, Firebird, SimpleDB, Elasticsearch, and MongoDB.

install script

sudo mkdir /usr/share/adminer
Read more

mysqld – Got packet bigger than ‘max_allowed_packet’ bytes when dumping table `memcache` at row

  1. Add --max_allowed_packet=512M to your mysqldump command.
  2. Or add max_allowed_packet=512M to [mysqldump] the section of your my.cnf

Note: it will not work if it is not under the [mysqldump] section…

Read more

Cron job for Automatic Feed updates in Openvas

To get updated content from the feeds you need to run the following scripts (in this order) on a daily base

# crontab -e

0 1 * * * /usr/sbin/greenbone-nvt-sync > /dev/null
0 2 * * * /usr/sbin/greenbone-scapdata-sync > /dev/null
0 3 * * * /usr/sbin/greenbone-certdata-sync > /dev/null

If there … Read more

How to Redirect HTTP to HTTPS in apache

Install modules

yum install -y mod_ssl  mod_rewrite

Enable modules

a2enmod rewrite
a2enmod ssl

Method 1

using rewrite module

<VirtualHost *:80>
ServerName www.yourdomain.com
  
RewriteEngine On 
RewriteCond %{HTTPS} !=on 
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
</VirtualHost>

Method 2

using redirect method

<VirtualHost *:80>
ServerName www.yourdomain.com 
  
Redirect permanent / https://www.yourdomain.com/
</VirtualHost>

Read more

How to use HiDPI(4K) resolution in Linux for all applications

HiDPI (High Dots Per Inch) displays, also known by Apple’s “Retina Display” marketing name, are screens with a high resolution in a relatively small format. They are mostly found in high-end laptops and monitors.

update this

~/.Xresources

Xft.dpi: 240

reboot or re-login to system

*240 dpi is suitable for 3840x2160 
Read more

How to RESET/FLUSH/DELETE all iptables in Linux

Take backup

iptables-save > ~/iptables-`date +%Y%m%d_%H%M%S`.bak

Flush now

iptables -F
iptables -X
iptables -t nat -F
iptables -t nat -X
iptables -t mangle -F
iptables -t mangle -X
iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -P OUTPUT ACCEPT

Again to restore from backup

iptables-restore < bak.file
Read more