Posts

Showing posts with the label Linux

Install docker Ubuntu 22.04

Install docker Ubuntu 22.04 Install docker Ubuntu 22.04 nano install_docker.sh #!/bin/bash # Update your existing list of packages sudo apt update # Install a few prerequisite packages which let apt use packages over HTTPS sudo apt install -y apt-transport-https ca-certificates curl software-properties-common # Add the GPG key for the official Docker repository to your system curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg # Add the Docker repository to APT sources echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null # Update the package database with Docker packages from the newly added repo sudo apt update # Make sure you are about to install from the Docker repo instead of the default Ubuntu repo sudo...

Do you need test you WAF / FRONT DOOR

Checking your WAF /  Front DOOR / Cloudflare is working Using the this in your request will get a block and you can see in the log. https://www.yourdomain.com/?a=b%20AND%201=1 ;-)

DSC Azure automation Linux

Have a problem in your DSC configuration. "Failed to apply the configuration. These resources produced errors: [nxFile]MyFolder. Detailed error information can be found in the log file.\"}"]

Nginx solution for check http_stub_status_module

Nginx add internal configuration to use http_stub_status_module

Nginx Reverse configuration

Simple Nginx proxy reverse configuration add the file proxy.conf in /etc/nginx/conf.d/ proxy_http_version 1.1; proxy_set_header Host               $http_host; proxy_set_header X-Real-IP          $remote_addr; proxy_set_header X-Forwarded-For    $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto  $scheme; proxy_set_header Upgrade            $http_upgrade; proxy_set_header Connection         "Upgrade";  Configuration for the domain simple server { listen 80; listen [::]:80; server_name example.com; location / {   include conf.d/proxy.conf; proxy_pass http://192.168.123.321:3000/; } }

How to pass value of a variable in ssh command

How make a script using a local or remote variable in other script  Sample SCRIPT  #!/bin/bash ## find the last or new backup file in the folder and create a variable name DBFILE DBFILE=`ssh -t serverB@192.0.0.1 "sudo find /temp/backup.sql -type f -mtime -1 -name "*.sql""`  ###( just show the name file) echo $DBFILE   ###  send the variable local to remote server echo here is DBFILE $DBFILE #ssh -t serverB@192.0.0.1 "sudo cp $DBFILE /home/user/" ## Script execute remote with the variable  #/usr/bin/scp serverB@192.0.0.1:/home/user/$DBFILE  /opt/temp

Compress MP4 files

How to compress the MP4 files. find . -type f -name "*.MP4" -exec bash -c 'FILE="$1"; ffmpeg -i "${FILE}" -s 1280x720 -acodec copy -y "${FILE%.mp4}.shrink.mp4";' _ '{}' \;

Varnish Exemple for CACHE and Optimisation

Varnish Optimisation cache # # This is an example VCL file for Varnish. # # It does not do anything by default, delegating control to the # builtin VCL. The builtin VCL is called when there is no explicit # return statement. # # See the VCL chapters in the Users Guide at https://www.varnish-cache.org/docs/ # and https://www.varnish-cache.org/trac/wiki/VCLExamples for more examples. # Marker to tell the VCL compiler that this VCL has been adapted to the # new 4.0 format. vcl 4.0; # Default backend definition. Set this to point to your content server. backend default { .host = "127.0.0.1"; .port = "8080"; } sub vcl_recv { # Happens before we check if we have this in cache already. # # Typically you clean up the request here, removing cookies you don't need, # rewriting the request, etc. # Happens before we check if we have this in cache already. # # Typically you clean up the request here, removing cookies you ...

Linux Compress PDF batch

#### gs gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/ebook -dNOPAUSE -dQUIET -dBATCH -sOutputFile=output.pdf $INPUTFILE ### pdf2ps && ps2pdf pdf2ps input.pdf output.ps && ps2pdf output.ps output.pdf ### Webservice http://compress.smallpdf.com/de For linux #!/bin/sh gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/default -dNOPAUSE -dQUIET -dBATCH -dDetectDuplicateImages -dCompressFonts=true -r150 -sOutputFile="compress_$@" "$@" ./compresspdf.sh file.pdf find -type f -name "*.pdf" -exec ./compresspdf.sh {} \; #!/bin/sh INPUT = $1 ; shift OUTPUT = $1 ; shift GS_BIN =/ usr / bin / gs QFACTOR = "0.40" # Image Compression Quality # # Quality HSamples VSamples QFactor # Minimum [2 1 1 2] [2 1 1 2] 2.40 # Low [2 1 1 2] [2 1 1 2] 1.30 # Medium [2 1 1 2] [2 1 1 2] 0.76 # High [1 1 1 1] [1 1 1 1] 0.40 # Maximum [1 1 1 1] [1 1 1 1] 0.15 $ { GS_BIN } - dBATCH - dSAFER - DNOPAUSE -...

resize images in Linux

Reduce images files png or jpg jpeg in subdirectories find -type f -name "*.jpeg" -exec jpegoptim --strip-all {} \; optipng *.png find -type f -name "*.png" -exec optipng {} \;

Haproxy Monitoring or BLOCK DDOS

How to monitor or block DDOS in Haproxy https://www.haproxy.com/blog/introduction-to-haproxy-stick-tables/ Configuration to monitor access This configuration just will TAG the external IP in the   abuse table, if need block something just remove the double #, to change the level of monitoring increase or reduce the number of connection   level. # ABUSE SECTION works with http mode dependent on src ip ## tcp-request content reject if { src_get_gpc0(Abuse) gt 5000 } acl abuse src_http_req_rate(Abuse) ge 5000 acl flag_abuser src_inc_gpc0(Abuse) ge 100 acl scanner src_http_err_rate(Abuse) ge 5000 # Abuse protection. # Sources that are not filtered. tcp-request content accept if { src -f /etc/haproxy/whitelist.lst } # Sources rejected immeditely. tcp-request content reject if { src -f /etc/haproxy/blacklist.lst } # Limiting the connection rate per client. No more than 5000 connections over 3 seconds. ## tcp-request content reject if { ...

SSH / Putty or similar freeze,

Image
Change the MTU Putty / SSH / Termius  freeze.  After changing the MTU of Windows TAP adapter to 1200, it works fine. 

Azure Debian apt update problem ?

Sometimes when the Debian is old, and you try to install or update something, the APT doesn't work in Debian machine in Azure VM, need to update the apt. I got these errors Err http://debian-archive.trafficmanager.net/debian/ jessie-backports/main pinen                                                                                                                                                     try-gtk2 amd64 0.9.7-5~bpo8+1   404  Not Found [IP: 52.233.239.54 80] Get:6 http://debian-archive.trafficmanager.net/debian/ jessie/main gnupg-agent a              ...

Haproxy error inconsistencies between private key and certificate loaded from PEM file

Error in haproxy with lets encrypt error msg bind *:443' : inconsistencies between private key and certificate loaded from PEM file '/etc/letsencrypt/live/ Need to create a new file cat cert.pem privkey.pem > haproxy_cert.pem Add in haproxy frontend www         bind *:80         bind *:443  ssl crt /etc/letsencrypt/live/mydomain.com/haproxy_cert.pem and make a test haproxy -c -V -f /etc/haproxy/haproxy.cfg

Instalando SARG ubuntu 14.04

Image
Instalando SARG ubuntu 14.04

Como limpar a partição de boot ubuntu

Image
Quando você tentar fazer a instalação de algum programa no ubuntu e ele diz que não é possível execute apt-get -f install para forçar ou continuar a instalar os pacotes etc, e fica em um loop eterno, o servidor deve estar com a partição de boot cheia, verifique o volume dando o comando df -h caso esteja em 100% execute o comando abaixo para limpar. uname -r verifique o KERNEL que o servidor tem instalado sudo dpkg --list 'linux-image*' removendo as versões não desejáveis. sudo dpkg -r linux-image-3.2.0-23-generic or sudo dpkg --force-depends --purge linux-image-3.2.0-23-generic

Munin Ubuntu 12.04

Image
Munin Para instalar sudo apt-get install munin Configurar sudo vim /etc/munin/munin.conf Arquivo do munin.conf # Example configuration file for Munin, generated by 'make build' # The next three variables specifies where the location of the RRD # databases, the HTML output, logs and the lock/pid files. They all # must be writable by the user running munin-cron. They are all # defaulted to the values you see here. # dbdir /var/lib/munin htmldir /var/www/munin logdir /var/log/munin rundir /var/run/munin # # Where to look for the HTML templates # tmpldir /etc/munin/templates # (Exactly one) directory to include all files from. # includedir /etc/munin/munin-conf.d # Make graphs show values per minute instead of per second #graph_period minute # Graphics files are normaly generated by munin-graph, no matter if # the graphs are used or not. You can change this to # on-demand-graphing by following the instructions...