How to , and other stuff about linux, photo, php … A linux, photography blog. To remember some linux situation, and fix them quickly.

February 6, 2018

Prevent SSL redirect loop using WordPress and HAProxy

Filed under: Linux — Tags: , , , , — admin @ 11:21 am

I do have a haproxy that is serving the ssl frontend and the apache is on 80 port.  But the wordpress see the 80 port and is not forcing to use the ssl as links for css/js

So to force wordpress to generate ssl internal links you need to add this into wp-config.php

define('FORCE_SSL_ADMIN', true);
define('FORCE_SSL_LOGIN', true);
if ($_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')
  $_SERVER['HTTPS']='on';


Offcourse on the haproxy you need to have

reqadd X-Forwarded-Proto:\ https

 

December 11, 2017

Redis can’t save in background

Filed under: Linux — Tags: , , — admin @ 10:53 am

Well I see something in log

[3765] 30 Jan 11:31:10 * 1 changes in 900 seconds. Saving…
[3765] 30 Jan 11:31:10 # Can’t save in background: fork: Cannot allocate memory

To fix this redis error you need to

echo 1 > /proc/sys/vm/overcommit_memory sysctl vm.overcommit_memory=1

 

December 8, 2017

delete large directory containing thousands of files

Filed under: Linux — Tags: , , , , , — admin @ 11:22 am

Well if you try to remove a directory with multiple files rm will take a long time also some load on that server .

One solution is to rsync a empty directory .

mkdir empty_dir
rsync -a –delete empty_dir/ yourdirectory/

Also a perl can be made but the rsync is easy for me to remeber .

Some more information about this you can find here

https://serverfault.com/questions/183821/rm-on-a-directory-with-millions-of-files/328305#328305

 

August 30, 2017

httpd with multiple ssl and password for every key automatically

Filed under: Linux — Tags: , , , , — admin @ 1:19 pm

Well to use this we must use the SSLPassPhraseDialog functionality of httpd – apache .

Basically into ssl.conf we put this line or modify the existing one into

SSLPassPhraseDialog exec:/path/script

Where script is read/execute only by root.

And the script is

 

#!/bin/perl
$server = $ARGV[0];
#print $server;
if ($server eq ‘www.example.com:443’ || $server eq ‘www.example2.com:443’ ) {
print ‘password one’;
} elsif ($server eq ‘example3.com’) {
print ‘Password two’;
}

 

June 27, 2017

change root password for mysql 5.7 fresh installed

Filed under: Linux — Tags: , , — admin @ 11:35 am

In order to find out actual password you need to grep log file

grep password /var/log/mysqld.log

This will provide you with root password .

After login on your mysql server with

mysql -u root -p

Then you must change root password with

ALTER USER ‘root’@’localhost’ IDENTIFIED BY ‘newpassword’;

 

« Newer PostsOlder Posts »

Powered by WordPress