Skip to content

Instantly share code, notes, and snippets.

View iammehrabalam's full-sized avatar

Md Mehrab Alam iammehrabalam

View GitHub Profile
For API speed and page responses:
---------------------------------
https://github.com/pagespeed/ngx_pagespeed
Nginx-Access-Plus is a Nginx module allows limiting access to certain http request methods and client addresses.
----------------------------------------------------------------------------------------------------------------
https://github.com/nginx-clojure/nginx-access-plus
This module can be used to protect your server in case system load or memory use goes too high.
-----------------------------------------------------------------------------------------------
@iammehrabalam
iammehrabalam / system_tuning.sh
Last active July 30, 2016 15:16
Linux system tuning
#!/bin/bash
# file descriptor
# Change 400000 to increase or decrease number of file descriptor
echo "* soft nofile 400000" >> /etc/security/limits.conf
echo "* hard nofile 400000" >> /etc/security/limits.conf
# Changing kernal parameters (modify value if required)
-- Debian packages nginx-extras, lua-zlib required
ngx.ctx.max_chunk_size = tonumber(ngx.var.max_chunk_size)
ngx.ctx.max_body_size = tonumber(ngx.var.max_body_size)
function create_error_response (code, description)
local message = string.format('{"status":400,"statusReason":"Bad Request","code":%d,"exception":"","description":"%s","message":"HTTP 400 Bad Request"}', code, description)
ngx.status = ngx.HTTP_BAD_REQUEST
ngx.header.content_type = "application/json"
ngx.say(message)
server {
server_name default_server;
listen 80;
location / {
proxy_pass http://localhost:8080;
proxy_set_header X-Real-IP $remote_addr;
client_max_body_size 5m;
client_body_buffer_size 5m;
## FOR UBUNTU
Dependencies install
1. apt-get install nginx-extras
2. apt-get install lua-zlib
lua file decompress request body
--------------------------------
see https://gist.github.com/iammehrabalam/30f5402bbcdad139c9eafd3a6f47ce6c
sudo apt-get install tor
# check tor service running on port 9050 (ss -aln | grep 9050)
# change ip after every 10 sec
edit vi /etc/tor/torrc and add MaxCircuitDirtiness 10
# use tor proxy in python request
install requests==2.10.0 (pip install requests==2.10.0) (currently 2.11 giving error)