Skip to content

Commit

Permalink
haproxy, drupal, linux
Browse files Browse the repository at this point in the history
  • Loading branch information
valentinsiryk committed Mar 3, 2017
1 parent fd02439 commit 257b731
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 8 deletions.
2 changes: 1 addition & 1 deletion drupal_apache_postgres.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ SSL::
sudo chmod 600 /etc/apache2/ssl/*


Virtual host config ``/etc/apache2/sites-available/drupal.conf``::
Create virtual host config ``/etc/apache2/sites-available/drupal.conf``::

<VirtualHost *:80>
ServerName www.mydrupal.co
Expand Down
40 changes: 40 additions & 0 deletions haproxy.txt
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,47 @@ HAProxy + LetsEncrypt
sudo apt install letsencrypt


``haproxy.cfg``::

frontend https-front-session
bind *:443 ssl crt /etc/ssl/le/one.example.com.pem crt /etc/ssl/le/two.example.com.pem
bind *:80

redirect scheme https if !{ ssl_fc }

default_backend back-session

acl is_le path_beg /.well-known/acme-challenge/
acl is_old hdr_end(host) -i one.example.com
acl is_new hdr_end(host) -i two.example.com

# Order is important
use_backend le if is_le
use_backend b1 if is_old
use_backend b2 if is_new

backend le
server letsencrypt 127.0.0.1:54321


Get cert::

sudo letsencrypt certonly --agree-tos --renew-by-default --standalone-supported-challenges http-01 --http-01-port 54321 -d <one.example.com>


``renewal.sh``::

#!/bin/sh

letsencrypt renew --agree-tos --standalone-supported-challenges http-01 --http-01-port 54321

DOMAIN=<one.example.com>
cat /etc/letsencrypt/live/$DOMAIN/fullchain.pem /etc/letsencrypt/live/$DOMAIN/privkey.pem > /etc/ssl/le/$DOMAIN.pem

DOMAIN=<two.example.com>
cat /etc/letsencrypt/live/$DOMAIN/fullchain.pem /etc/letsencrypt/live/$DOMAIN/privkey.pem > /etc/ssl/le/$DOMAIN.pem

service haproxy reload


Geolocation
Expand Down
30 changes: 23 additions & 7 deletions linux_commands.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ Show listening ports::
netstat -antup


Change group::

chgrp [-R] <GID/gname>


arp // ARP таблица содержит адреса устройств, с которыми взаимодействует данная ОС. А так же MAC'и
-n // только IP(без доменов)
Expand Down Expand Up @@ -183,20 +187,32 @@ wget -qO- 127.0.0.1 # get and show page

sed -i "s@SOURCE@DEST@g" /path/to/file

# find
# https://ru.wikipedia.org/wiki/Find
Find
----

- https://ru.wikipedia.org/wiki/Find

::

find ./ -name 'path*' # find files
-type (f=файл, d=каталог, l=ссылка (link), p=канал (pipe), s=сокет) # type of file
find ./ -name 'path*'
-type (f=file, d=dir, l=link, p=pipe, s=socket)

find ./ -mtime 0 -type f -not -path "./" -exec cp --parents "{}" $TODAY_DIR/ \;

find . -type f -exec chmod 644 {} \; # chmod only files
# chmod only files
find . -type f -exec chmod 644 {} \;

# faster chmod only files
find . -type f -print0 | xargs -0 chmod 644

# make iconv replace the input file with the converted output in one line
find . -type f -name '*.php' -exec sh -c 'iconv -f WINDOWS-1251 -t UTF-8 -o {}UTF_TMP {} && mv {}UTF_TMP {}' \;

################
Delete old files::

Delete old files
----------------

::

ls -t | sed -e '1,10d' | xargs -d '\n' rm -f
ls -t # lists all files in the current directory in decreasing order of modification time
Expand Down

0 comments on commit 257b731

Please sign in to comment.