Skip to content

Instantly share code, notes, and snippets.

View majudhu's full-sized avatar
🤔
live curios, why not

Majudhu majudhu

🤔
live curios, why not
View GitHub Profile
@majudhu
majudhu / nginx.conf
Created March 18, 2024 18:06
nginx nextjs expressapi
server {
server_name example.com;
client_max_body_size 100M; # allow huge uploads, upto 100MB
root /home/pm2/nextapp/public; # serve static files from public dir with nginx
try_files $uri @next; # serve static files with nginx, fallback to nextjs on not found
location @next {
@majudhu
majudhu / nginx.conf
Created October 25, 2023 14:46
Remix NGINX config
server {
server_name example.com;
client_max_body_size 100M; # allow huge uploads, upto 100MB
root /home/user/example/public/; # serve static files from public dir with nginx
try_files $uri @remix; # serve static files with nginx, fallback to nextjs on not found
location /build {
@majudhu
majudhu / gen-cert.sh
Created October 4, 2023 19:21
nginx geo whitelist and ssl snakeoil
openssl req -x509 -newkey rsa:4096 -nodes -sha256 -keyout /etc/ssl/private/ssl-cert-snakeoil.key -out /etc/ssl/certs/ssl-cert-snakeoil.pem -days 3650 -subj "/CN=<$PUBLIC_IP_ADDRESS>"

Keybase proof

I hereby claim:

  • I am majudhu on github.
  • I am majudhu (https://keybase.io/majudhu) on keybase.
  • I have a public key whose fingerprint is D575 0441 16D7 D92C D492 A038 95E6 A79D 7B19 0AC5

To claim this, I am signing this object:

@majudhu
majudhu / etc nginx cf_real_ip
Last active September 6, 2022 18:07
cloudflare nginx real ip expressjs req.ip trust_proxy
proxy_headers_hash_max_size 1024;
proxy_headers_hash_bucket_size 128;
# https://www.cloudflare.com/ips/
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;
@majudhu
majudhu / strapi.js
Created August 23, 2022 21:14
Strapi Wrappers for Next.js
const API_URL = 'http://localhost:1337/api/';
const OPTIONS = { headers: { Authorization: `Bearer ${TOKEN}` } };
async function query(path) {
return (await fetch(API_URL + path, OPTIONS)).json();
}
export async function getList(path) {
const data = await query(path);
return data.data.map(({ id, attributes }) => ({ id, ...attributes }));
@majudhu
majudhu / etc-danted.conf
Last active February 27, 2022 07:56
git npm ssh socks proxy
internal: 0.0.0.0 port=8888
external: eth0
socksmethod: none
clientmethod: none
client pass {
from: 0.0.0.0/0 to: 0.0.0.0/0
}
@majudhu
majudhu / grub
Created February 3, 2022 20:13
/etc/default/grub asus ux331 mx150
GRUB_DEFAULT=saved
GRUB_TIMEOUT=1
GRUB_TIMEOUT_STYLE=hidden
GRUB_DISTRIBUTOR="Manjaro"
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash apparmor=1 security=apparmor udev.log_priority=3 udev.log_priority=3 noirqdebug pci=noaer i915.enable_psr=0 idle=nomwait i915.enable_dc=0 i915.enable_fbc=0 processor.max_cstate=1 rcu_nobs=0-11 i915.enable_gvt=1 kvm.ignore_msrs=1"
GRUB_CMDLINE_LINUX=""
# If you want to enable the save default function, uncomment the following
# line, and set GRUB_DEFAULT to saved.
GRUB_SAVEDEFAULT=true
@majudhu
majudhu / pgp.txt
Last active June 20, 2021 15:01
PGP Public Key
-----BEGIN PGP PUBLIC KEY BLOCK-----
mDMEXw8Q9hYJKwYBBAHaRw8BAQdAPqAvsfCNNRE7crfTijQUWOPA5cDGSP2+xu/h
U+qchZe0LE1hanVkaHUgKG1hanVkaHUuY28pIDxtYWp1ZGh1LnN1cEBnbWFpbC5j
b20+iJYEExYIAD4WIQTVdQRBFtfZLNSSoDiV5qedexkKxQUCXw8Q9gIbAwUJCWYB
gAULCQgHAgYVCgkICwIEFgIDAQIeAQIXgAAKCRCV5qedexkKxRsXAPkBkLsb1AXG
sPNdG5W11Sw5X40prgH3QxqB1GVv+y43uwEAxPjXh7ulz9TCtJK6H23jm2TpJdO2
k7WMX6WDknJP2AO4OARfDxD2EgorBgEEAZdVAQUBAQdAN7MwsW6QIYSo5vlws56s
6FyV7uQOG/8M75F0VERvwmkDAQgHiH4EGBYIACYWIQTVdQRBFtfZLNSSoDiV5qed
exkKxQUCXw8Q9gIbDAUJCWYBgAAKCRCV5qedexkKxYoAAQCz7w5OiZMU+bB4dscF
@majudhu
majudhu / nginx.conf
Last active May 30, 2024 14:35
nginx with nextjs and expressjs api
proxy_cache_path /var/cache/nginx keys_zone=my_cache:20m use_temp_path=off;
proxy_cache my_cache;
proxy_cache_lock on;
proxy_cache_lock_timeout 20s;
map $http_authorization $cachecontrol {
"" "public, max-age=10, s-maxage=5, stale-while-revalidate=20";
}
server {