Skip to content

Instantly share code, notes, and snippets.

andybeak

Block or report user

Report or block andybeak

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@andybeak
andybeak / Dockerfile
Created Dec 4, 2019
Lab 4 - Laravel in ECS
View Dockerfile
FROM php:7.2-apache
COPY --chown=www-data:www-data . /var/www/html/
COPY Docker/vhost.conf /etc/apache2/sites-available/000-default.conf
COPY Docker/php.ini-development /usr/local/etc/php/php.ini
WORKDIR /var/www/html/
@andybeak
andybeak / fingerscrossed.php
Created Dec 3, 2019
Monolog fingerscrossed handler
View fingerscrossed.php
<?php
// composer require monolog/monolog
require('vendor/autoload.php');
use Monolog\Logger;
use Monolog\Handler\StreamHandler;
use Monolog\Handler\FingersCrossedHandler;
use Monolog\Handler\FingersCrossed\ErrorLevelActivationStrategy;
@andybeak
andybeak / iptables.sh
Last active Nov 21, 2019
Set up firewall for webserver behind a reverse proxy #book #course
View iptables.sh
#!/bin/bash
logger Configuring iptables
# Flush existing rules
sudo iptables -F
# Allow SSH from bastion server
sudo iptables -A INPUT -p tcp -s 172.31.23.163/32 --dport 22 -m conntrack --ctstate NEW,ESTABLISHED -j ACCEPT
sudo iptables -A OUTPUT -p tcp --sport 22 -m conntrack --ctstate ESTABLISHED -j ACCEPT
@andybeak
andybeak / go.sh
Last active Nov 30, 2019
Get AWS Ubuntu Linux VM ready for remote development #book #course
View go.sh
#!/bin/bash
sudo apt update && sudo apt upgrade -y
sudo apt-get install -y \
apt-transport-https \
ca-certificates \
curl \
gnupg-agent \
software-properties-common
@andybeak
andybeak / index.php
Created Nov 12, 2019
Blog article on monolog to ELK #blog
View index.php
<?php
require('../vendor/autoload.php');
use Monolog\Logger;
use Monolog\Handler\SocketHandler;
// create a log channel
$log = new Logger('elk');
@andybeak
andybeak / logout.php
Last active Oct 21, 2019
Log out a user using server-side sessions
View logout.php
<?php
// can't log out if the session isn't started
session_start();
// emptying the session data is useful if your script continues running after logging out
$_SESSION = [];
// set the cookie to expire immediately
if (ini_get("session.use_cookies")) {
$params = session_get_cookie_params();
setcookie(session_name(), '', time() - 42000,
$params["path"], $params["domain"],
@andybeak
andybeak / nginx_tls.conf
Last active Nov 22, 2019
Nginx TLS config #book
View nginx_tls.conf
server {
listen 443 ssl;
server_name example.com;
ssl on;
# enable HSTS
add_header Strict-Transport-Security "max-age=63072000; includeSubdomains;";
# prevent clickjacking
add_header X-Frame-Options "SAMEORIGIN";
@andybeak
andybeak / nginx.conf
Last active Aug 22, 2019
nginx cors allow origins #course #book
View nginx.conf
// See https://nginx.org/en/docs/http/ngx_http_map_module.html
// This sets the value of $cors_header depending on the value of $http_origin
map $http_origin $cors_header{
default "";
"~^(https:\/\/safedomain\.com)$" "$http_origin";
"~^(https:\/\/anotherdomain\.com)$" "$http_origin";
}
server {
listen 80;
View gist:3817d12fb94af49b3d6037c2f0eca134
<?php
// Answer from https://stackoverflow.com/questions/7648623/dynamically-running-clamavs-clamscan-on-file-uploads-with-php
$safe_path = escapeshellarg($_FILES['uploadedfile']['tmp_name']);
$command = 'clamscan ' . $safe_path;
$out = '';
$int = -1;
exec($command, $out, $int);
@andybeak
andybeak / docker-compose.yml
Created Mar 21, 2019
NomadPHP php speed comparison demo
View docker-compose.yml
version: '3'
services:
nginx:
image: nginx:1.13.1
container_name: nginx-proxy
ports:
- "80:80"
- "443:443"
volumes:
- conf:/etc/nginx/conf.d
You can’t perform that action at this time.