cloudflare

Apache Show Real IP Address when using CloudFlare

When using Apache web server behind cloudflare, apache logs show cloudflare IP address instead of real visitor IP address. To show actual visitor IP address, you need to install mod_cloudflare apache module.

Before you can install the module, you need to install following requirments.

On Debian/Ubuntu server,

Now install mod_cloudflare with

Restart apache web server with

Verify mod_cloudflare apache module is loaded with

apache cloudflare module

MySQL

MySQL ERROR 1193 Unknown system variable GTID_PURGED

When restoring MySQL backup taken on Amazon RDS, i get error

To fix this, open db.sql in text editor, remove the line

Another solution is take a new MySQL backup with –set-gtid-purged=OFF option and restore it.

mysql create database

MySQL create database

To create a database, you can use

Example

To create a database with specific charset use

You can use whatever character set you wish instead of utf8mb4.

Example

mysql create database

To delete a database, use

Install PHP 7 on CentOS VestaCP

To install PHP 7. you need to first enable epel and remi repo.

Remove existing PHP

Install PHP 7.3

start php-fpm

Set php 7.3 as default PHP for cli

Restart apache

Configure Nginx Reverse Proxy behind Cloudflare

On reverse proxy server, lets install some basic utilities.

Install nginx

Now create a config file

Add following to the file and save

In above replce following

Next create a self signed SSL certificate for the web site

Restart nginx

At this stage, you can login to cloudflare, point IP of the web site to reverse proxy server IP address.

Show real IP address

When running a site behind reverse proxy, by default, web server shows IP of the revese proxy server instead of real visitor IP. To fix this, you need to configure remoteip module.

On Cpanel server, edit file

Find

Add your proxy server IP after.

Example

VestaCP Update

To update VestaCP server, run

Example

Redirect site to HTTPS excluding a folder

On a web site, customer need to redirect all pages to HTTPS, but want to keep files in one of the folder on HTTP.

For this, i used following in .htaccess file.

Here any url like yourdomain.extn/auth/ will not get redirected to HTTPS.

See Redirect

rpmdb DB_RUNRECOVERY: Fatal error, run database recovery

When running yum update on a CentOS server, i get following error.

To fix it, run