Skip to content

Instantly share code, notes, and snippets.

@amber46
amber46 / nginx.conf
Created February 25, 2024 13:25 — forked from Stanback/nginx.conf
Example Nginx configuration for adding cross-origin resource sharing (CORS) support to reverse proxied APIs
#
# CORS header support
#
# One way to use this is by placing it into a file called "cors_support"
# under your Nginx configuration directory and placing the following
# statement inside your **location** block(s):
#
# include cors_support;
#
# As of Nginx 1.7.5, add_header supports an "always" parameter which
@amber46
amber46 / vzdump-hook-script.pl
Created May 23, 2021 16:05 — forked from meramsey/vzdump-hook-script.pl
Perl script that uploads backup files to cloud storage using rclone, removes backups older then 1 week.
#!/usr/bin/perl -w
# example hook script for vzdump (--script option)
use strict;
print "HOOK: " . join (' ', @ARGV) . "\n";
my $phase = shift;

In case there's already a DHCP config for netplan for the private IP address:

File: /etc/netplan/50-cloud-init.yaml

Contents:

# This file is generated from information provided by
# the datasource.  Changes to it will not persist across an instance.
# To disable cloud-init's network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
@amber46
amber46 / Ubuntu-Creating-Swap-File
Created March 17, 2021 14:35 — forked from raykao/Ubuntu-Creating-Swap-File
How to create a swap file on ubuntu 12.04. Summary from: [Digital Ocean](https://www.digitalocean.com/community/articles/how-to-add-swap-on-ubuntu-12-04)
# Summary from: https://www.digitalocean.com/community/articles/how-to-add-swap-on-ubuntu-12-04
# 1. Check if swap exists returns single line output if swap doesn't exist
$ sudo swapon -s
Filename Type Size Used Priority
# 2. Check disk space on root (/) with DF command:
$ df
Filesystem 1K-blocks Used Available Use% Mounted on
@amber46
amber46 / promtail.yml
Created January 17, 2021 14:05
Promtail config for syslog and extract labels from nginx logs
---
server:
http_listen_port: 9080
grpc_listen_port: 0
positions:
filename: /tmp/positions.yaml
client:
@amber46
amber46 / percona-toolkit-my.cnf
Created July 26, 2019 10:04 — forked from michaeljoy/percona-toolkit-my.cnf
pt-heartbeat systemd init script example - percona tookit systemd examples
[mysql]
host=localhost
socket=/var/run/mysqld/mysqld.sock
[client]
host=localhost
socket=/var/run/mysqld/mysqld.sock
@amber46
amber46 / proxy.apache.conf
Created February 7, 2019 06:21 — forked from chrisjhoughton/proxy.apache.conf
Sample Nginx reverse proxy to Apache set up for Wordpress.
<VirtualHost *:{PORT}>
ServerName www.yourdomain.com
ServerAdmin [email protected]
DocumentRoot /var/www/yourdir/
<Directory /var/www/yourdir>
Options Indexes FollowSymLinks
AllowOverride all
Order allow,deny

Better SSH Authorized Keys Management

A seemingly common problem that people encounter is how to handle all of your users authorized_keys file.

People struggle over management, ensuring that users only have specific keys in the authorized_keys file or even a method for expiring keys. A centralized key management system could help provide all of this functionality with a little scripting.

One piece of functionality overlooked in OpenSSH is the AuthorizedKeysCommand configuration keyword. This configuration allows you to specify a command that will run during login to retrieve a users public key file from a remote source and perform validation just as if the authorized_keys file was local.

Here is an example directory structure for a set of users with SSH public keys that can be shared out via a web server:

sudo add-apt-repository -y ppa:ondrej/php
sudo apt-get update
sudo apt-get install -y php7.2-fpm
sudo apt-get install -y php7.2
sudo apt-get -y install curl php7.2-pgsql php7.2-curl php7.2-json php7.2-mbstring php7.2-gd php7.2-intl php7.2-xml php7.2-imagick php7.2-redis php7.2-zip
# sudo systemctl disable apache2
@amber46
amber46 / php-fpm-cli
Created June 4, 2018 15:25 — forked from chrisLeeTW/php-fpm-cli
php-fpm-cli with status & ping function.
#!/bin/bash
#
# The MIT License (MIT)
#
# Copyright (c) 2014 Mathias Leppich <[email protected]>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell