Skip to content

Instantly share code, notes, and snippets.

View glagola's full-sized avatar

Igor Glagola glagola

View GitHub Profile
@glagola
glagola / example.com.conf
Created April 19, 2019 22:20
Nginx config: remove repeat slashes
# https://www.example.com -> https://example.com
# http://www.example.com -> http://example.com
# *://example.com////// -> *://example.com
# *://example.com//////asdfasdfasd///asdfasdf// -> ..(multiple redirects).. -> *://example.com/asdfasdfasd/asdfasdf
server {
server_name www.example.com;
return 301 $scheme://bitwide.com$request_uri;
}
@glagola
glagola / gist:134b86f3b59f46b5ecd9c67318c66ac1
Last active April 25, 2020 19:49 — forked from corvax19/openssh-encrypt-decrypt.txt
Simple text encryption/decryption with openssl
echo -n "That's the text" | openssl enc -aes-256-cbc -md sha512 -pbkdf2 -iter 100000 -salt | openssl base64 > /tmp/a
Encrypt with interactive password. Encrypted message is base64-encoded afterwards.
cat /tmp/a | openssl base64 -d | openssl enc -aes-256-cbc -md sha512 -pbkdf2 -iter 100000 -salt -d
Base-64 decode and decrypt message with interactive password
server {
listen 80;
server_name server.ru;
location ~* ^/i/([^./]*) {
proxy_ignore_headers Expires Cache-Control;
proxy_cache_lock on;
proxy_cache_valid 24h;
proxy_cache_valid 404 1m;
@glagola
glagola / dig
Created December 11, 2015 09:09
dig +nocmd domain.com any +multiline +noall +answer
#!/bin/bash
## Copyright (C) 2009 Przemyslaw Pawelczyk <przemoc@gmail.com>
## License: GNU General Public License v2, v3
#
# Lockable script boilerplate
### HEADER ###
LOCKFILE="/var/lock/`basename $0`"
<?php
class HttpError extends Exception { }
class Curl {
private $ch;
private $headers;
protected function baseSettings() {
@glagola
glagola / rsync-through-middle-hop.sh
Last active January 4, 2016 17:28
rsync through middle host
rsync -ar --rsh='ssh -TA MiddleHost ssh -TA ' TargetHost:/rsync/from /where/to/rsync
@glagola
glagola / .bashrc
Created August 8, 2013 14:16
.bashrc
#
# ~/.bashrc
#
# If not running interactively, don't do anything
[[ $- != *i* ]] && return
alias ls='ls --color=auto'
alias l='ls -l'
alias ll='ls -l'
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
index index.html index.htm index.php .dirindex.php;
try_files $uri $uri/ =404;
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
log_not_found off;