Racktables is a software solution for datacenter and server room asset management. It helps document hardware assets, network addresses, space in racks, VLAN, etc…
You can find more info on the subject on the official website.
Racktables is a software solution for datacenter and server room asset management. It helps document hardware assets, network addresses, space in racks, VLAN, etc…
You can find more info on the subject on the official website.
Apache has a very convenient feature: loading setting files from a webapp directories on the fly. These .htaccess
files allow you to tweak the server’s behavior without access to the standard setting files. That a killer feature in a shared hosting environment but beside this particular case, you shouldn’t use it. Why ? Because there are serious drawback !
Performance hit
When AllowOverride all
is used Apache will look for .htaccess
files in every directory on the path of each served files. That pretty bad but it gets even worse: for each request the content of every .htaccess
is read again. As you can imagine that a serious performance hit.
Security concern
Not all parameters can be overridden into .htaccess
files, but there is already a lot you can do with a little imagination. For example an attacker could use an application vulnerability to modify a .htaccess
in order to add a new file handler, so that .jpeg
files are now processed by PHP.
By doing this he can now bypass most webapp upload ‘protection’ mechanism. You can sure the next .jpeg
upload will not be a picture of a busty girl but something way more nasty, like a C99 shell.
Maintainability concern
Sometimes a customer will complain that a particular rewrite rule or a specific php setting doesn’t behave like expected. That weird, because you are sure you made ββthe appropriate changes. Surprise surprise, the behavior is altered into a .htaccess
file, hidden somewhere in a 5-depth directory structure.
Integrate htaccess content into standard setting files
Many applications come with their own .htaccess
. This file generally contain all the required rewrites rules to ensure their proper functioning. It can be very annoying to adapt its content into a standard apache setting file, because the syntax isn’t completely the same.
Fortunately there is a small tip that will save you a lot of trouble and time: you can just copy the rewrites rules into your main Directory
block and then add a RewriteBase /
line into it.
Let say you have a file with multiple sections, delimited by the character sequence -|
, and you need to create multiple files, one for each section. How you do that ?
Basically you can use three tools for the job.
Use csplit
Csplit is a very useful and not well know utility, present into coreutils
package.
csplit --quiet --prefix=outfile infile.txt "/-|/+1" "{*}"
Use awk
awk '{print $0 " -|"> "output" NR}' RS='-\\|' infile.txt
Use bash/perl/python
Here i give you the bash one-liner version, but you can also use perl, python, ruby or any other scripting language:
cat infile.txt | ( I=0; echo -n "" > output0; while read line; do echo $line >> output$I; if [ "$line" == '-|' ]; then I=$[I+1]; echo -n "" > output$I; fi; done )
CCZE is a fast log colorizer written in C intended to be a replacement for other terminal colorizer like colorize (made in perl) and grc/grcat (made in python). CCZE is way more faster then it predecessor, and come with twenty preset profile for thing like exim, fetchmail, apache, postfix, php and syslog log file. CCZE can also colorize you terminal input, if you add the -A
parameter.
Usage
ccze /var/log/foobar.log
As usual you can add a pipe for more
(or less π ) usage:
ccze /var/log/foobar.log | more
For less
don’t forget to add the -R
option for ANSI colors interpretation:
tail -n 50 /var/log/foobar.log | ccze -A | less -R
This error append when trying to upload a file bigger than 1Mbits on a platform using Nginx as an HTTP server or reverse-proxy/SSL off-loader. That because Nginx, by default, limit client query size.
You can change the upper value using the client_max_body_size
directive into Nginx setting file:
# vi /etc/nginx/nginx.conf
client_max_body_size <new_value>;
Note: if you want to disable this behavior, set the value to 0.
It’s crazy how long (and error prone) this simple operation can be when done by hand. But there is a very simple command to do it ‘automagically’ :
ssh-keygen -i -f stupid_putty_format.pub > good_key_format.pub
As varnish
doesn’t have any persistent storage you shoul avoid restart it, beside modifications on health checks, backend definitions or changes on the vcl_hash routine.
To reload varnish
configuration you could use the distribution init script, or you can do it by hand:
# varnishadm -S /etc/varnish/secret -T 127.0.0.1:6082
vcl.load conf_two /etc/varnish/prod.vcl
vcl.use conf_two
quit
Note that you can use these commands to load multiple setting files and switch between them on the fly.
Put in place a basic HTTP authentication on a website with a Varnish can be a little tricky.
If you add the authentication on the backend without any changes into the varnish configuration, as soon as an authenticated client browse the website, filtered contents will be accessible to other users.
To avoid this behavior you can add the following block into your vcl_recv :
if (req.http.Authorization) {
return (pass);
}
but that mean bypassing all cache for the filtered-content. If you want to protect the whole website this setting make Varnish completely useless. Fortunately, it is possible to implement the HTTP authentication on the Varnish side.
Encode user and password
As varnish is a reverse-proxy and not an HTTP server, there is nothing surprising in the fact that there is no support for password file. To bypass this limitation, we will add the login and password directly inside Varnish’s configuration, encoded into a base64
string, generated like this:
# echo -n "$LOGIN:$PW" | base64
VCL modifications
Into the vcl_recv add this block:
if (! req.http.Authorization ~ "Basic XXXXXXXXXXXX"){
error 401 "Restricted" ;
}
where XXXXXXXXXXXX is your base64 encoded string.
Then add into the vcl_error :
if (obj.status == 401) {
set obj.http.Content-Type = "text/html; charset=utf-8";
set obj.http.WWW-Authenticate = "Basic realm=Secured";
synthetic {"
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
<HTML>
<HEAD>
<TITLE>Forbidden</TITLE>
<META HTTP-EQUIV='Content-Type' CONTENT='text/html;'>
</HEAD>
<BODY><H1>401 Forbidden</H1></BODY>
</HTML>
"};
return (deliver);
}
List the max value of open file descriptors
You can use the following command:
# sysctl fs.file-max
Or
# cat /proc/sys/fs/file-max
Increase the file-max value
# sysctl -w fs.file-max=100000
To make the change permanent:
# vi /etc/sysctl.conf
fs.file-max = 100000
Don’t forget to sysctl -p
to reload the setting file.
User level FD limits
Beside the system maximum value, there is also two limits (hard and soft) for user account. You can check theses values using ulimit
like this:
# ulimit -Hn
# ulimit -Sn
You can override theses values for a specific user if needed, into the /etc/security/limits.conf
file. To get the list of the most greedy process, use this snippet:
lsof +c 15 | awk '{printf("%15s (%s)\n", $1, $2)}' | sort | uniq -c | sort -rn