Top Nav

Archive | Apache

Get Top 10 User Agents

Extract a list of the top user agents from an Apache format log file and sort in descending order by number of occurrences:

Results similar to this:

 

 

0

Fixing “Size of a request header field exceeds server limit.” error

This error from Apache is typically caused by a very large cookie. In Apache the “LimitRequestFieldSize” directive sets this limit. The default is 8190 bytes. To change the file create a file at:

/etc/httpd/conf.d/custom.conf

or

/etc/apache2/conf.d/custom.conf

containing the desired change:

Reload Apache after adding the file with:

/sbin/service apache2 restart

or

/sbin/service httpd restart

0

Clearing PHP opcache

Great article on how to clear the PHP opcache:

https://ma.ttias.be/how-to-clear-php-opcache/

To facilitate use on a Plesk server created script and mapped into namespace:

https://acme.com/opcache_clear

Here’s the script:

And here’s the Apache config to map into a virtual host:

This above config should be placed in the “Apache & nginx setting” screen in the “Additional directives for https” field. In addition to setting the alias path we’re also setting the PHP handler.

Additionally under “Password protected directories” added password protection for “/opcache_clear”. This is just a placeholder for the password file which is referenced in the above config.

0

Apply Basic Auth To Site With Excluded Virtual Path Under Plesk With Apache 2.4

We want to password protect a WordPress development site but allow unauthenticated access to the wp-json/ path. Hosting platform is Plesk with Apache 2.4. We’ll assume the domain is “acme.com” and the assigned IP is “w.x.y.z”.

There are probably better ways to accomplish the goal but this approach seems to work.

Step 1. – In Plesk add a Protected Directory named “/donotremove” and add appropriate user/passwords.

Step 2. – In Plesk on the “Apache & nginx Setting” screen under “Additional nginx directives” add the following:

Step 3. – In Plesk on the “Apache & nginx Setting” screen under “Additional directives for HTTP” and “Additional directives for HTTPS” add the following:

 

 

 

0

.htaccess – negative file type match

Here’s an example of how to block all files extensions not listed in the regular expression:

 

0