Skip to content

Instantly share code, notes, and snippets.

View serverok's full-sized avatar
🎯
Focusing

Yujin Boby serverok

🎯
Focusing
View GitHub Profile
server {
listen *:443 ssl;
server_name DOMAINNAME www.DOMAINNAME ;
root /var/www/verifier/;
index index.php index.html index.htm;
access_log /var/log/nginx/DOMAINNAME.log;
error_log /var/log/nginx/DOMAINNAME.error.log;
ssl_certificate /etc/letsencrypt/live/DOMAINNAME/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/DOMAINNAME/privkey.pem;
# Implement TLS 1.3 0-RTT anti-replay for NGINX
# Requires: NGINX directive "ssl_early_data" on
# Usage:
# Make sure these "map" blocks are included in "http" block
# Put the following two lines in SSL "server" block, before any "location" blocks
# if ($anti_replay = 307) { return 307 https://$host$request_uri; }
-----BEGIN DH PARAMETERS-----
MIICCAKCAgEA7N3ZOcXgACR0Rat9G/7h8krD7ysVvmEmvAdg8o5l7eKVdtp/QSNK
anF0JyInJMBEgq05GY7YwvFovglJL73T/eEjTK3qPU6eHzxNGKfR0pM6rnAb+EXL
dSNJm3Xz9wH4IKn6OJ3nD9aLmBVI5FlIMV1R4QKX3sIWUxRqRSQIzjNQTnY1e/Pk
BT/ZrUUF7fPPVbg0nPD8Y48ISr7pB6M14Kr66cggGIqUVdBdkPYyt4RpFWR1n3Tv
rz1j0U+UoVnan2FgGsSiSFT9I/CiIxgC/SrdwxZLUgbAiKsnw9H7nGW92C4cRqY0
2eKMVNEBk32GSPQXaA+Q5TILyzxuwDbXMxHMxnUVKQGFEcXjWXXyiv7tLAeu68Do
j5iNFOHbDp17SftnxYHi2vTsYk+9K6Pzc+NmUgibM52Rs92PPYd++HcgMeGrYcqi
temHP2jPtAymixch0wdqBMgeGTb29w51LR0BAU6D6BeR25pkZvPUag3bb6SU1Oli
E15DDWh3UnmfTw2M9W1uxlzQAlXOLL6/ZWuvwyqhCY6X7tIONtSgdYGjtiTFaPJp
# Cloudflare IP Ranges
# IPv4
set_real_ip_from 103.21.244.0/22;
set_real_ip_from 103.22.200.0/22;
set_real_ip_from 103.31.4.0/22;
set_real_ip_from 104.16.0.0/13;
set_real_ip_from 104.24.0.0/14;
set_real_ip_from 108.162.192.0/18;
set_real_ip_from 131.0.72.0/22;
# Server globals
user www-data;
worker_processes auto;
worker_rlimit_nofile 65535;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
include /etc/nginx/conf.d/main/*.conf;
include /etc/nginx/modules-enabled/*.conf;
# Worker config
@serverok
serverok / gist:712b85432d188f16c9d32e44455b419a
Created October 25, 2024 20:45
netplan bridge network config
before
root@ns5028044:~# cat /etc/netplan/50-cloud-init.yaml
network:
version: 2
ethernets:
eno1np0:
match:
macaddress: "9c:6b:00:3f:4f:f9"
addresses:
@serverok
serverok / gist:03d39aa0fcdabb24ac4df0e8006a7477
Created September 8, 2024 07:03
PHP function to identify Mobile Users
function is_mobile()
{
if (empty($_SERVER["HTTP_USER_AGENT"])) {
return false;
}
return @preg_match("/(android|webos|avantgo|iphone|ipad|ipod|blackberry|iemobile|bolt|boost|cricket|docomo|fone|hiptop|mini|opera mini|kitkat|mobi|palm|phone|pie|tablet|up\.browser|up\.link|webos|wos)/i", ''.$_SERVER["HTTP_USER_AGENT"]);
}
function is_iphone()
{
@serverok
serverok / gist:a6c084d6b6a11a674c93dd2b89bf46bf
Created September 8, 2024 06:59
PHP function to find visitor IP
function find_user_ip()
{
foreach (array('HTTP_CF_CONNECTING_IP', 'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR') as $key) {
if (array_key_exists($key, $_SERVER) && !empty($_SERVER[$key])) {
foreach (@explode(',', ''.$_SERVER[$key]) as $ip) {
$ip = trim($ip);
if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false) {
return $ip;
}
}
@serverok
serverok / gist:2043ad4e171127387f0eb3d8aaabcc55
Last active September 7, 2024 10:54
Server to Server File Transfer with PHP script
<?php
# Author: ServerOK
# Web: https://serverok.in/server-to-server-file-transfer-with-php-script
# URL of the file to be downloaded
$source_url = 'https://example.com/backup.zip';
$filename = basename(parse_url($source_url, PHP_URL_PATH));
$destination_path = __DIR__ . '/' . $filename;
Reaplce YOUR-DOMAIN.EXT with you actual domain or subdomain. Point domain to server IP by editing DNS.
To create a new wordpress site, create a dirctory
/var/www/YOUR-DOMAIN.EXT/public_html
Upload wordpress files inside.
Create nginx config