How to fix 413 Request Entity Too Large in nginx

If you’re encountering the “413 Request Entity Too Large” error in Nginx, it means the server is rejecting requests that exceed the configured size limit. You can fix this by increasing the client_max_body_size directive in your Nginx configuration.

Steps to Increase Request Size:

  1. Edit the Nginx Configuration File
    Open your Nginx config file (nginx.conf or site-specific config in /etc/nginx/sites-available/):sudo nano /etc/nginx/nginx.conf Or, if modifying a specific site:sudo nano /etc/nginx/sites-available/default
  2. Increase client_max_body_size
    Add or modify the following line inside the http, server, or location block:client_max_body_size 100M; Adjust the value (100M) based on your needs.
  3. Save and Exit
    • If using nano, press CTRL + X, then Y, and Enter to save.
  4. Restart Nginx to Apply Changes
    sudo systemctl restart nginx
  5. Verify Configuration
    Check if the changes were applied correctly:sudo nginx -t

If you’re also using PHP-FPM, you may need to adjust upload_max_filesize and post_max_size in php.ini.

Installing an SSH key on a Debian server

Installing an SSH key on a Debian server involves generating the key pair, transferring the public key, and configuring SSH for authentication. Here’s a step-by-step guide:

1. Generate the SSH Key Pair

On your local machine, generate an SSH key pair using the following command:

ssh-keygen -t rsa -b 4096

  • You can also use ed25519 for better security:

ssh-keygen -t ed25519

  • Save the key in the default location (~/.ssh/id_rsa) or specify a custom path.
  • You may set a passphrase for extra security.

2. Copy the Public Key to the Debian Server

Use ssh-copy-id to transfer your public key to the remote server:

ssh-copy-id user@your-debian-server-ip

If ssh-copy-id is unavailable, manually copy the key:

cat ~/.ssh/id_rsa.pub | ssh user@your-debian-server-ip “mkdir -p ~/.ssh && chmod 700 ~/.ssh && cat >> ~/.ssh/authorized_keys && chmod 600 ~/.ssh/authorized_keys” 

3. Verify SSH Key Authentication

Try logging in without a password:

ssh user@your-debian-server-ip

4. (Optional) Disable Password Authentication

For extra security, edit the SSH configuration file on the server:

sudo nano /etc/ssh/sshd_config

  • Find and set:

PasswordAuthentication no

  • Save and restart SSH:

sudo systemctl restart ssh

Fix /var/log/cron filesize

If your /var/log/cron file is growing too large due to excessive script output, you can take a few steps to control the logging behavior. Here’s how you can fix it:

1. Modify Your Cron Jobs

  • The output of cron jobs is typically sent to /var/log/cron by default if not redirected. To minimize the logging:
    • Redirect the standard output (stdout) and standard error (stderr) of your cron jobs to a file or to /dev/null (to discard output): * * * * * /path/to/your/script.sh > /dev/null 2>&1
      • > /dev/null discards standard output.
      • 2>&1 redirects standard error to standard output.

2. Adjust Verbosity in Scripts

  • If possible, review your scripts and reduce unnecessary logging or verbosity. For example, avoid printing debug or informational messages unless needed.

3. Change Cron Logging Configuration

  • On many systems, cron logging is controlled by syslog or rsyslog. To reduce the log volume:
    • Edit the syslog configuration file (commonly /etc/rsyslog.conf or /etc/syslog.conf): # Reduce cron log verbosity cron.* /var/log/cron You can change cron.* to a less verbose level (e.g., cron.warning or cron.err).
    • Restart the syslog service: sudo systemctl restart rsyslog

4. Rotate the Logs

  • Implement log rotation to automatically manage the size of /var/log/cron. Most systems have logrotate installed:
    • Edit or create a logrotate configuration file for cron (e.g., /etc/logrotate.d/cron): /var/log/cron { daily rotate 7 compress missingok notifempty }
    • This will keep logs for 7 days and compress old ones.

5. Monitor with Care

  • Be cautious when discarding output entirely, as it might hide errors. Ensure critical errors or messages are logged to an appropriate location.

By combining these methods, you can regain control over your /var/log/cron file while keeping essential logs intact. Do you want help applying any of these suggestions?

Batch Script Backup for MySQL Windows to Winrar

Make sure mysqldump is set in the environment or use the full path to the program.

@echo off
SET MYSQL_USER=root
SET MYSQL_PASS=yourpassword
SET MYSQL_HOST=localhost
SET WINRAR_PATH="C:\Program Files\WinRAR\WinRAR.exe"

REM Get current date components
FOR /F "tokens=2-4 delims=/ " %%A IN ('date /t') DO (
    SET MONTH=%%A
    SET DAY=%%B
    SET YEAR=%%C
)

REM List of databases to export
SET DATABASES=database1 database2 database3

REM Loop through each database, create a backup, and compress it with WinRAR
for %%D in (%DATABASES%) do (
    echo Exporting database %%D...
    mysqldump -u %MYSQL_USER% -p%MYSQL_PASS% -h %MYSQL_HOST% %%D > %%D_backup_%MONTH%_%DAY%_%YEAR%.sql

    echo Compressing %%D_backup_%MONTH%_%DAY%_%YEAR%.sql...
    %WINRAR_PATH% a -r %%D_backup_%MONTH%_%DAY%_%YEAR%.rar %%D_backup_%MONTH%_%DAY%_%YEAR%.sql

    echo Cleaning up raw SQL file...
    del %%D_backup_%MONTH%_%DAY%_%YEAR%.sql
)

echo Done! Each database backup is compressed into a WinRAR archive.

Winrar Monthly Backup Script

I use this script to backup websites and data each month it takes a list of paths and uses winrar via command line appending the current month day year.

@echo off
setlocal enabledelayedexpansion

:: Define the list of folders to archive
set "folders=C:\path\site1 C:\path\site2 C:\path\site3"

:: Get current date components
for /f "tokens=2 delims==" %%I in ('wmic OS Get localdatetime /value') do set datetime=%%I
set "year=!datetime:~0,4!"
set "month=!datetime:~4,2!"
set "day=!datetime:~6,2!"

:: Define WinRAR path (update accordingly)
set "winrar_path=C:\Program Files\WinRAR\WinRAR.exe"

:: Iterate over folders and create archives
for %%F in (%folders%) do (
    for %%A in ("%%F") do set "folder_name=%%~nA"
    set "rar_name=!folder_name!_files_!month!!day!!year!.rar"

    echo Archiving "%%F" as "!rar_name!" with 50GB splits...
    "%winrar_path%" a -r -v50g "!rar_name!" "%%F"
)

echo All archives created successfully with 50GB splits.
endlocal
pause

Pass UTM TAGS Webflow page to all links such as other subdomains/sites

<script>
document.addEventListener('DOMContentLoaded', function(event) {

// create urlParams variable (constant) from URLSearchParams class using current window
const urlParams = new URLSearchParams(window.location.search);
// set UTM medium, source and campaign variables (constants) based on results of URSearchParams
const utm_medium = urlParams.get('utm_medium') || "";
const utm_source = urlParams.get('utm_source') || "";
const utm_campaign = urlParams.get('utm_campaign') || "";
const utm_term = urlParams.get('utm_term') || "";
const utm_content = urlParams.get('utm_content') || "";

const ref_link = urlParams.get('ref') || "";

// get the Outbound button element
links = document.querySelectorAll("a");

links.forEach(function(outboundLink) {
// edit Outbound button element property by appending the URL parameters
var finalLink = "";
if (utm_medium != "")
finalLink += "utm_medium=" + encodeURIComponent(utm_medium);

if (utm_source != "")
{
if (finalLink != "")
finalLink += "&";

finalLink += "utm_source=" + encodeURIComponent(utm_source);
}

if (utm_campaign != "")
{
if (finalLink != "")
finalLink += "&";

finalLink += "utm_campaign" + encodeURIComponent(utm_campaign);
}


if (utm_term != "")
{
if (finalLink != "")
finalLink += "&";

finalLink += "utm_term=" + encodeURIComponent(utm_term);
}

if (ref_link != "")
{
if (finalLink != "")
finalLink += "&";

finalLink += "ref=" + encodeURIComponent(ref_link);
}

if (finalLink != "")
outboundLink.href += "?" + finalLink;

// log final Outbound button link to console
// console.log(outboundLink.href);
});

    } );
</script>
Based on https://stackoverflow.com/a/65297467

Legacy PHP Functions

Just setup a small github repo of some deprecated php function replacements.
I have many websites that I maintain and other old software and always trying to stay on the latest version of PHP. These functions help if you are going from PHP 5 to PHP 7 and PHP 7 to PHP 8

Includes: mysql_* create_function ereg eregi ereg_replace eregi_replace split spliti


https://github.com/VBGAMER45/legacyphpfunctions

Installing Elastic Search 8.0 on CentOS 8 Orcale Linux

A quick guide on setting up Elastic Search

yum install java-1.8.0-openjdk.x86_64
cd /etc/yum.repos.d/
ls
vi elasticsearch.repo
yum install –enablerepo=elasticsearch elasticsearch
systemctl start elasticsearch.service

curl –cacert /etc/elasticsearch/config/certs/http_ca.crt -u elastic hcurl –cacert /etc/elasticsearch/certs/http_ca.crt -u elastic https://localhost:9200

yum install kibana
cd /etc/yum.repos.d/
vi kibana.repo
yum install kibana

/usr/share/elasticsearch/bin/elasticsearch-create-enrollment-token -s kibana
/bin/systemctl daemon-reload
/bin/systemctl enable kibana.service

sestatus
setsebool httpd_can_network_connect 1 -P

systemctl status firewalld

firewall-cmd –new-zone=elastic-access –permanent


firewall-cmd –zone=elastic-access –add-source=192.68.0.1 –permanent

firewall-cmd –zone=elastic-access –add-port=9200/tcp –permanent

firewall-cmd –zone=elastic-access –add-port=9300/tcp –permanent
firewall-cmd –zone=elastic-access –add-port=5601/tcp –permanent

firewall-cmd –zone=elastic-access –add-port=80/tcp –permanent
firewall-cmd –zone=elastic-access –add-port=443/tcp –permanent

firewall-cmd –reload

/usr/share/kibana/bin/kibana-verification-code

netstat -ntlp

yum -y install nginx httpd-tools

cd /etc/nginx/conf.d

vi es.yoursite.com.conf

nginx -t

service nginx restart