Skip to content

Instantly share code, notes, and snippets.

View eksiscloud's full-sized avatar

Jakke Lehtonen eksiscloud

View GitHub Profile
@eksiscloud
eksiscloud / matomo.conf
Created January 27, 2020 17:22
Basic virtual host for Matomo in Nginx
server {
listen [::]:80; # remove this if you don't want Matomo to be reachable from IPv6
listen 80;
server_name analytics.example.com;
access_log /var/log/nginx/matomo.access.log;
error_log /var/log/nginx/matomo.error.log;
root /var/www/matomo/;
@eksiscloud
eksiscloud / matomo.ssl.conf
Created January 27, 2020 16:31
A Live example of Matomo nginx virtua host in stack Nginx/Varnish/Apache2
server {
listen 46.101.98.116:443 ssl http2;
server_name stats.eksis.eu;
access_log /var/log/nginx/access.matomo.log;
error_log /var/log/nginx/error.matomo.log;
location / {
proxy_pass http://127.0.0.1:8080;
proxy_set_header X-Real-IP $remote_addr;
@eksiscloud
eksiscloud / matomo.conf
Created January 27, 2020 16:18
Basic virtual host for Matomo in Apache2
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName analytics.example.com
DocumentRoot /var/www/matomo/
<Directory /var/www/matomo>
DirectoryIndex index.php
Options FollowSymLinks
AllowOverride All
Require all granted
@eksiscloud
eksiscloud / S3GlacierVault
Created January 14, 2020 17:25
How to delete AWS S3 Glacier vault
1. aws glacier initiate-job --job-parameters '{"Type": "inventory-retrieval"}' --vault-name YOUR_VAULT_NAME --account-id YOUR_ACCOUNT_ID --region YOUR_REGION
2. aws glacier list-jobs --vault-name YOUR_VAULT_NAME --region YOUR_REGION --account-id YOUR_ACCOUNT_ID
try again and again until you get "Completed": true, and "StatusCode": "Succeeded"
it can take several hours or days
3. aws glacier get-job-output --job-id YOUR_JOB_ID --vault-name YOUR_VAULT_NAME --region YOUR_REGION --account-id YOUR_ACCOUNT_ID ./output.json
copy job_id from the output of the second step
4. nano glacier.php
@eksiscloud
eksiscloud / example.tld.conf
Created December 22, 2019 23:17
Apache2 virtual conf: behind Varnish, PHP-FPM, redirects needed by Wordpress (category in url), WP Rocket and EWWW
<VirtualHost 127.0.0.1:81>
ServerAdmin <email>
ServerName example.tld
ServerAlias www.example.tld
DocumentRoot /var/www/html
LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b \"%{User-agent}i\"" varnishcombined
CustomLog ${APACHE_LOG_DIR}/access.log varnishcombined
@eksiscloud
eksiscloud / example.tld.conf
Last active December 22, 2019 20:40
Nginx: Virtual host and SSL + HTTP/2 before Varnish in port 8080 (backend is Apache2), redirecting from port 80 to port 443, map for normal 301 redirects
map_hash_bucket_size 256;
map $request_uri $new_uri {
include /etc/nginx/snippets/includes/301.example.tld.map;
}
server {
listen <ip-address>:443 ssl http2;
server_name example.tld www.example.tld;
@eksiscloud
eksiscloud / wget
Last active March 19, 2021 12:03
Warm up of reverse proxy like Varnish using wget
wget --spider -o wget.log -e robots=off -r -l 5 -p -S -T3 --header="X-Bypass-Cache: 1" -H --domains=example.tld --show-progress www.example.tld
# Options explained
# --spider: Crawl the site
# -o wget.log: Keep the log
# -e robots=off: Ignore robots.txt
# -r: specify recursive download
# -l 5: Depth to search. I.e 1 means 'crawl the homepages'. 2 means 'crawl the homepage and all pages it links to'...
# -p: get all images, etc. needed to display HTML page
# -S: print server response (to the log)
@eksiscloud
eksiscloud / functions.php
Last active June 22, 2020 10:20
Wordpress: Allow/disallow uploading different type/mime files
add_filter( 'upload_mimes', 'my_mime_types', 1, 1 );
function my_mime_types( $mime_types ) {
$mime_types['jpg|jpeg|jpe'] = 'image/jpeg';
$mime_types['gif'] = 'image/gif';
$mime_types['png'] = 'image/png';
$mime_types['bmp'] = 'image/bmp';
$mime_types['tiff|tif'] = 'image/tiff';
$mime_types['ico'] = 'image/x-icon';
$mime_types['asf|asx'] = 'video/x-ms-asf';
@eksiscloud
eksiscloud / functions.php
Created December 4, 2019 14:47
Woocommerce: Remove euro symbol without CSS
function eksis_remove_wc_currency_symbol( $currency_symbol, $currency ) {
if (!is_cart()){
$currency_symbol = '';
return $currency_symbol;
}
}
add_filter('woocommerce_currency_symbol', 'eksis_remove_wc_currency_symbol', 10, 2);
@eksiscloud
eksiscloud / functions.php
Created December 4, 2019 14:43
Add WooCommerce customer username to edit/view order admin page
// Add WooCommerce customer username to edit/view order admin page
add_action( 'woocommerce_admin_order_data_after_billing_address', 'woo_display_order_username', 10, 1 );
function woo_display_order_username( $order ){
global $post;
$customer_user = get_post_meta( $post->ID, '_customer_user', true );
echo '<p><strong style="display: block;">'.__('Customer Username').':</strong> <a href="user-edit.php?user_id=' . $customer_user . '">' . get_user_meta( $customer_user, 'nickname', true ) . '</a></p>';
}