Monday, February 12, 2018

Enable socket admin Haproxy

The stats socket is not enabled by default. In order to enable it, it is
necessary to add one line in the global section of the haproxy configuration.
A second line is recommended to set a larger timeout, always appreciated when
issuing commands by hand :

    global
        stats socket /var/run/haproxy.sock mode 600 level admin
        stats timeout 2m

It is also possible to add multiple instances of the stats socket by repeating
the line, and make them listen to a TCP port instead of a UNIX socket. This is
never done by default because this is dangerous, but can be handy in some
situations :

    global
        stats socket /var/run/haproxy.sock mode 600 level admin
        stats socket ipv4@192.168.0.1:9999 level admin
        stats timeout 2m

Saturday, October 21, 2017

Free SSL Certificate with Let's Encrypt


1. Install git
apt-get install git

2. Create Let's Encrypt source directory
mkdir /opt/letsencrypt

3. Clone source of Let's Encrypt
git clone https://github.com/letsencrypt/letsencrypt /opt/letsencrypt

4. Stop web server (apache, tomcat, nginx...) because they can cause of port 443 error

5. Create certificate for specified domain
cd /opt/letsencrypt 
./letsencrypt-auto certonly --standalone -d example.com -d www.example.com

6. All certificates have created in /etc/letsencrypt/live

7. Config fullchain.pem for certificate file, privkey.pem for key file

For HaProxy, create .pem file
cat fullchain.pem privkey.pem > secure.pem

By default, Let's Encrypt issue certificate valid for 90 days, so we need config automatically renew it

1. create auto_renew_cert.sh file as below:
cd /opt/letsencrypt
git pull
service nginx stop
./letsencrypt-auto certonly --quiet --standalone --renew-by-default -d example.com
service nginx start


2.  execute it in crontab monthly
echo '@monthly root sh /root/auto_renew_cert.sh >> /var/log/letsencrypt/letsencrypt-auto-update.log' | sudo tee --append /etc/crontab





Saturday, June 24, 2017

Portable Postgres

Postgres full extension 9.6.3 on Debian 8 64bit 
https://drive.google.com/open?id=0B30EeVPAcvhvWHpMNDZmbFdNYVk

Friday, March 17, 2017

Install Redmine

gem install passenger --no-ri --no-rdoc
passenger-install-nginx-module

http://coderazzi.net/linux/debian/redmine.htm

Thursday, February 9, 2017

Function slower than query direct Postgres

For queries on tables with even data distribution, this will generally be no problem and PL/pgSQL functions will perform somewhat faster than raw SQL queries or SQL functions. But if your query can use certain indexes depending on the actual values in the WHERE clause or, more generally, chose a better query plan for the particular values, you may end up with a sub-optimal query plan.
(source: http://stackoverflow.com/questions/9305133/why-does-postgresql-treat-my-query-differently-in-a-function)

RETURN QUERY : cache plan
RETURN QUERY EXECUTE: replan for each call

RETURN QUERY EXECUTE $$
//query body
$$ USING param1, param2

Saturday, February 4, 2017

Monday, January 30, 2017