Skip to content

Instantly share code, notes, and snippets.

View aamsur-mkt's full-sized avatar

Aam S aamsur-mkt

View GitHub Profile
@aamsur-mkt
aamsur-mkt / ThrottleRequests.php
Created October 12, 2020 04:51 — forked from developerdino/ThrottleRequests.php
Lumen Middleware for rate limiting - based on Laravel's implementation.
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Response;
use Illuminate\Cache\RateLimiter;
class ThrottleRequests
{
@aamsur-mkt
aamsur-mkt / my.cnf
Created September 20, 2020 16:18 — forked from fevangelou/my.cnf
Optimized my.cnf configuration for MySQL/MariaSQL (on Ubuntu, CentOS etc. servers)
# Optimized my.cnf configuration for MySQL/MariaSQL
#
# by Fotis Evangelou, developer of Engintron (engintron.com)
#
# ~ Updated January 2020 ~
#
#
# The settings provided below are a starting point for a 2GB - 4GB RAM server with 2-4 CPU cores.
# If you have different resources available you should adjust accordingly to save CPU, RAM & disk I/O usage.
#
@aamsur-mkt
aamsur-mkt / stress-test.sh
Created September 9, 2020 09:25 — forked from cirocosta/stress-test.sh
naive http server stress tester using cURL
#!/bin/bash
#### Default Configuration
CONCURRENCY=4
REQUESTS=100
ADDRESS="http://localhost:8080/"
show_help() {
cat << EOF
@aamsur-mkt
aamsur-mkt / README.md
Created February 25, 2020 10:51 — forked from NiceGuyIT/README.md
nginx JSON to Filebeat to Logstash to Elasticsearch

Intro

This is an example configuration to have nginx output JSON logs to make it easier for Logstash processing. I was trying to get nginx > Filebeat > Logstash > ES working and it wasn't until I connected Filebeat directly to Elasticsearch that I saw the expected data. Google led me to ingest-convert.sh and I realized filebeat setup works for Filebeat > ES but not Filebeat > Logstash > ES. This is because Logstash does not use ingest pipelines by default. You have to enable them in the elasticsearch output block.

Having nginx log JSON in the format required for Elasticsearch means there's very little processing (i.e. grok) to be done in Logstash. nginx can only output JSON for access logs; the error_log format cannot be changed.

Extra fields are output and not used by the Kibana dashboards. I included them in case they might be useful. Since they are not declared in the filebeat setup, their default is "string" when yo

@aamsur-mkt
aamsur-mkt / KongJwt.md
Created December 12, 2019 08:55 — forked from martinheld/KongJwt.md
Short example to use JWT with Kong

JWT Kong Example

  • Get and Start Kong and Co
git clone git@github.com:Mashape/docker-kong.git
cd docker-kong/compose
docker-compose up
  • Create Kong API Route
@aamsur-mkt
aamsur-mkt / limt_req_zone_whitelist
Last active November 1, 2023 12:23 — forked from skaag/limt_req_zone_whitelist
A way to whitelist certain IP ranges from limit_req_zone in nginx
geo $whitelist_ip {
default 1;
# Your office ip
127.0.0.1/32 0;
}
map $whitelist_ip $default_limit {
1 $binary_remote_addr;
0 "";