Skip to content

Instantly share code, notes, and snippets.

View trongnghia203's full-sized avatar
🤠

Nghia Le trongnghia203

🤠
View GitHub Profile

NGINX 1.10 + APACHE 2.4 real IP for reverse proxy

Edit nginx conf

default.conf or what you want

vim /etc/nginx/conf.d/default.conf

add proxy_set_header for php files

@trongnghia203
trongnghia203 / private-docker-regs-with-free-tiers.markdown
Created October 6, 2023 13:48 — forked from JakubOboza/private-docker-regs-with-free-tiers.markdown
Private Docker registry with free tiers for Developers.

List of sites with free tier limits

  • Docker Hub - One private repo/image spot for free
  • Three Scale - Very generous free tier 50GB of space, 500 Pulls a month etc..
  • Canister - 20 private repos with almost no limits on free tier
  • Code Fresh - Free tier for developers

Setup your own private registry

/**
* Retrieves all the rows in the active spreadsheet that contain data and logs the
* values for each row.
* For more information on using the Spreadsheet API, see
* https://developers.google.com/apps-script/service_spreadsheet
*/
function readRows() {
var sheet = SpreadsheetApp.getActiveSheet();
var rows = sheet.getDataRange();
var numRows = rows.getNumRows();

Three system configuration parameters must be set to support a large number of open files and TCP connections with large bursts of messages. Changes can be made using the /etc/rc.d/rc.local or /etc/sysctl.conf script to preserve changes after reboot.

1. /proc/sys/fs/file-max: The maximum number of concurrently open files.

fs.file-max = 1000000

2. /proc/sys/net/ipv4/tcp_max_syn_backlog: Maximum number of remembered connection requests, which are still did not receive an acknowledgment from connecting client. The default value is 1024 for systems with more than 128Mb of memory, and 128 for low memory machines.

net.ipv4.tcp_max_syn_backlog = 3240000

3. /proc/sys/net/core/somaxconn: Limit of socket listen() backlog, known in userspace as SOMAXCONN. Defaults to 128.

net.core.somaxconn = 3240000

@trongnghia203
trongnghia203 / mysql_html_backup.sh
Created September 25, 2020 23:17
Backup MySQL and html directory
#!/bin/bash
DATE=`date +"%Y%m%d_%H%M"`
BK_DEST="/onedrive/"
NUMBER_OF_BACKUPS=30
DATABASES=$(mysql -sN -e 'show databases' | grep db_)
cd /tmp

SSH agent forwarding and screen

When connecting to a remote server via SSH it is often convenient to use SSH agent forwarding so that you don't need a separate keypair on that server for connecting to further servers.

This is enabled by adding the

ForwardAgent yes

option to any of your Host entries in ~/.ssh/config (or alternatively with the -A option). Don't set this option in a wildcard Host * section since any user on the remote server that can bypass file permissions can now als use keys loaded in your SSH agent. So only use this with hosts you trust.

@trongnghia203
trongnghia203 / setup_puppet_masterless.md
Created June 27, 2020 13:57
Set-up a masterless puppet environment

Setup a Masterless Puppet Environment

Setup Puppet Masterless

@trongnghia203
trongnghia203 / README.md
Last active June 27, 2020 12:58
Bash: Backup MySQL

Backup mysql

Usage:

Create a cron job

crontab -e

Add following lines

@trongnghia203
trongnghia203 / install_pyenv.md
Last active April 19, 2024 13:37
Install pyenv