Posts Tagged ‘snippet’

One more short snippet, that might be useful to me in the future. If you have a website served by Apache and want your clients to only use HTTPS, you can use this mod_rewrite configuration:

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L]

If the server then gets any HTTP request, it will redirect the client to the same URL, but with the https scheme. This means that actual requests will be only ever served via HTTPS.

Another post mainly for myself, just so I know where to find the information quickly the next time I need it. If you have swap on a LVM volume, these commands can be used to resize it (in this case, increase by 100MB):

swapoff /dev/vg_foo/lv_swap
lvextend -L+100M /dev/vg_foo/lv_swap
mkswap /dev/vg_foo/lv_swap
swapon /dev/vg_foo/lv_swap

That is: disable swapping on the volume, extend it, re-create the swap area and enable swapping again.

(This post is mostly for myself, because I know I’ll forget the exact syntax next I need it)

I’ve recently discovered that instead of ssh to one machine and then ssh to another machine in the local network, I can configure ssh to start the proxy connection automatically.  For example:

Host example-local-10
    HostName 192.168.0.10
    ProxyCommand ssh example.com nc %h %p 2> /dev/null

Especially useful when working with various tools that just use the ssh transport protocol, like scp or rsync.