Skip to content

Instantly share code, notes, and snippets.

View petecooper's full-sized avatar
🏴‍☠️

Pete Cooper petecooper

🏴‍☠️
View GitHub Profile
@pandrewhk
pandrewhk / FreeBSD 13.2 arm64 on Hetzner CAX11 Installation
Last active September 26, 2023 17:46
FreeBSD 13.2 arm64 on Hetzner CAX11
- # download VIMAGE to a spare FreeBSD box
- unxz -T0 # uncompress
- mdconfig image.raw; mount # for editing
- sshd_enable
- devmatch_blacklist="virtio_random.ko" # avoid a bug
- PermitRootLogin
- /root/.ssh/authorized_keys
- umount; mdconfig -d
- xz -T0 -9 # compress edited image
- cp nginx/ # publish with any web server
@muuvmuuv
muuvmuuv / how-to-php-fpm-pm-optimized.md
Last active June 2, 2024 06:33
Get optimized PHP-fpm "pm" config
@kerns
kerns / nginx_error_setup.txt
Last active March 29, 2023 13:05
One NGINX Error Page to Rule Them All
In /etc/nginx/ I have a file called errors.conf, which should try and pass errors to a error.php file in /var/www/admin/public
----
# Error handler, codes can also be combined
error_page 401 /error.php?c=401;
error_page 403 /error.php?c=403;
error_page 404 /error.php?c=404;
error_page 500 /error.php?c=500;
error_page 502 503 504 /error.php?c=50x;
Source: https://www.cyberciti.biz/tips/linux-unix-bsd-nginx-webserver-security.html
This page collects hints how to improve the security of nginx web servers running on Linux or UNIX-like operating systems.
Default Config Files and Nginx Port
/usr/local/nginx/conf/ or /etc/nginx/– The nginx server configuration directory and /usr/local/nginx/conf/nginx.conf is main configuration file.
/usr/local/nginx/html/ or /var/www/html– The default document location.
/usr/local/nginx/logs/ or /var/log/nginx – The default log file location.
Nginx HTTP default port : TCP 80
@april
april / nginx.csp.conf
Created July 12, 2016 19:08
Simple NGINX config to dump CSP reports
server {
listen 80;
server_name site.mozilla.org;
location / {
return 301 https://$server_name$request_uri;
}
location /twohundredinator {
access_log off;
@fer-ri
fer-ri / restart-service.sh
Last active May 7, 2023 11:39
Auto Restart PHP5-FPM When Down or Bad Gateway
#!/bin/bash
if curl --head -sf http://yourdomain.com/some-script.php -o /dev/null; then
echo "PHP FPM is up"
else
service php5-fpm restart && service nginx restart && service mysql restart
echo "Opps .. service was down" | mail -s "PHP-FPM Service Down" yourmail@domain.com -aFrom:cron@yourmail.com
fi
@DavidWells
DavidWells / reset.css
Last active June 25, 2024 18:15 — forked from karbassi/reset.css
CSS reset. Follow me on the twitters for more tips: https://twitter.com/davidwells
/* http://meyerweb.com/eric/tools/css/reset/
v2.0-modified | 20110126
License: none (public domain)
*/
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
@magnetikonline
magnetikonline / README.md
Last active December 14, 2023 06:45
Nginx FastCGI cache configuration example.

Nginx FastCGI cache

Example /etc/nginx/nginx.conf using FastCGI (e.g. to PHP-FPM) with FastCGI cache enabled. This will capture returned data and persist it to a disk based cache store for a configurable amount of time, great for robust full page caching.

Will need to create a directory to hold cache files, for the example given here that would be:

$ sudo mkdir -p /var/cache/nginxfastcgi
$ chown www-data: /var/cache/nginxfastcgi
@denji
denji / nginx-tuning.md
Last active June 27, 2024 04:48
NGINX tuning for best performance

Moved to git repository: https://github.com/denji/nginx-tuning

NGINX Tuning For Best Performance

For this configuration you can use web server you like, i decided, because i work mostly with it to use nginx.

Generally, properly configured nginx can handle up to 400K to 500K requests per second (clustered), most what i saw is 50K to 80K (non-clustered) requests per second and 30% CPU load, course, this was 2 x Intel Xeon with HyperThreading enabled, but it can work without problem on slower machines.

You must understand that this config is used in testing environment and not in production so you will need to find a way to implement most of those features best possible for your servers.