Skip to content

Instantly share code, notes, and snippets.

View riyas-rawther's full-sized avatar

Riyas Rawther riyas-rawther

View GitHub Profile
@riyas-rawther
riyas-rawther / fix-wordpress-permissions.sh
Created November 20, 2020 04:34 — forked from Adirael/fix-wordpress-permissions.sh
Fix wordpress file permissions
#!/bin/bash
#
# This script configures WordPress file permissions based on recommendations
# from http://codex.wordpress.org/Hardening_WordPress#File_permissions
#
# Author: Michael Conigliaro <mike [at] conigliaro [dot] org>
#
WP_OWNER=www-data # <-- wordpress owner
WP_GROUP=www-data # <-- wordpress group
WP_ROOT=$1 # <-- wordpress root directory
@riyas-rawther
riyas-rawther / .gitlab-ci.yml
Created December 7, 2021 08:19
gitlab-ci.yml file for running a pipeline only on a specific branch, using specific runners and when releasing (tag) manually.
deploy_development:
stage: deploy
only:
- development # Limit this job to the staging branch
script:
- echo "Deploy to staging server"
- cd /var/www/stagingadmin.example.com
- sudo git stash
- sudo git fetch
- sudo git pull
@riyas-rawther
riyas-rawther / gist:38968571e6e6606e4991ba32d0dc725f
Created September 17, 2022 10:57
NGINX code block to redirect to WordPress login page, when the user is not login.
//add this file to your site's configuration. It usually located inside the sites-enabled folder.
location ~ ^/wp-content/uploads/(?<file>restricted/.*)
{
rewrite ^ /dl.php?file=$file last;
// get the dl.php from https://www.youtube.com/shorts/GLiDRC9dbPg
}
@riyas-rawther
riyas-rawther / dl.php
Created September 17, 2022 11:01
PHP file to redirect to WordPress login page, when trying to access a particular file from a folder.
<?php
require_once('wp-load.php');
is_user_logged_in() || auth_redirect();
list($basedir) = array_values(array_intersect_key(wp_upload_dir(), array('basedir' => 1)))+array(NULL);
$file = rtrim($basedir,'/').'/'.str_replace('..', '', isset($_GET[ 'file' ])?$_GET[ 'file' ]:'');
@riyas-rawther
riyas-rawther / send-alert-if-sensu-docker-is-down
Created January 30, 2023 01:58
send an email alert when a port is down using python3
#!/bin/python3
import smtplib, ssl, socket
from email.mime.text import MIMEText
port = 465 # For SSL
msg = MIMEText('Sensu is Down!. Please do the needful')
msg['Subject'] = 'Sensu is down!'
msg['From'] = 'noreply.xxxx@gmail.com'
msg['To'] = 'riyas.rawther@xxxx.com'
@riyas-rawther
riyas-rawther / python-flask.conf
Created August 31, 2023 15:57
NGINX configuration file for multiple Python Flask applications with reverse proxy. Use this config file to have dedicated static files per location (nested)
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name example.com;
# SSL
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
ssl_trusted_certificate /etc/letsencrypt/live/example.com/chain.pem;