Easily kill remote desktop sessions to your server

This is more of a future reference post, but if you have the same problem we sometimes face with lots of developers logging into the same remote win2003 server, where both terminal sessions are taken. And sometimes both are taken by the developer who's just gone on holidays! So then you either have to drag you butt down to the server room to kill sessions from the terminal or even worse ring up the data centre for a hosted box.

Well fret no more! you can run the following commands easily to kill any remote sessions to a box from a winXP (and vista i presume?) or parallels for the macl33t

1: Open windows command prompt

2: to view current connections: qwinsta /server:myserver

This results in an output of

SESSIONNAME USERNAME ID STATE TYPE DEVICE
console administrator 0 Active wdcon
rdp-tcp 65536 Listen rdpwd
rdp-tcp#51 administrator 2 Active rdpwd

3: kill a session by: rwinsta [sessionID] /server:myserver

i.e. rwinsta 2 /server:myserver

CFMX Multi Instance Apache config - made simple

If the title makes sense then the rest of the article will be a breeze.

For some the hardest part of Apache is the fact that there is no GUI (Graphical User Interface) for the configuration. To me it's the reason I love apache! While it might be a bit daunting if you are new to Apache the power and flexibility that the text file configuration gives you is simply not feasible in an GUI.

At RedBalloon we have a number of different sites and a number of different servers so being able to manage the config files and lay them out to suit our needs it a huge boost. On top of this, we version our config files using subversion which gives us backups, rollback and a version history.

The windows installer sets up a basic and very well commented config which is a great base to start from. We typically add the following line at the end to allow simple loading of the virtual host config files:

Include cont/vhost/*.conf

Each vhost file consists of a number of related virtual host sections:

Listen 127.0.0.1:80
Listen 127.0.0.1:443

NameVirtualHost 127.0.0.1:80
NameVirtualHost 127.0.0.1:443
#Site 1
<VirtualHost 127.0.0.1:80> #HTTP
   <-- removed for clarity -->
</VirtualHost>
<VirtualHost 127.0.0.1:443> # HTTPS
   <-- removed for clarity -->
</VirtualHost>
#Site 2
<VirtualHost 127.0.0.1:80>
   <-- removed for clarity -->
</VirtualHost>
<VirtualHost 127.0.0.1:443>
   <-- removed for clarity -->
</VirtualHost>

We deliberately add listen directives at the top of the vhost file to easy migration of sites from one machine to another. All settings for a particular site are in one spot.

The sites in any one file are all related - i.e. for redballoon we have the main consumer site, our suppliers extranet site etc all in the one config.

The inner sections of the virtual host looks as follows:

<VirtualHost 127.0.0.1:80>
Include conf/cfinstance/example1-instance.conf

DocumentRoot /path/to/wwwroot
ServerName www.example.com

Include conf/aliases/example1-aliases.conf
</VirtualHost>
<VirtualHost 127.0.0.1:443>
Include conf/cfinstance/example1-instance.conf
Include conf/ssl/example1-ssl.conf

DocumentRoot /path/to/wwwroot
ServerName www.example.com

Include conf/aliases/example1-aliases.conf
</VirtualHost>

By moving all of the common/repeated lines out to well named include files the vhost section is very simple to read and understand. It also makes it easy to add an alias across common sites or change the cfinstance the website is using.

Each of the include files is just the lines that would be directly in the file pulled out to an external file.

Eg - the cfinstance/example1-instance

JRunConfig Serverstore /opt/jrun4/lib/wsconfig/1/jrunserver.store
# Bootstrap port is what specifies which instance to be used - see the JRun admin for the relevant numbers
JRunConfig Bootstrap 127.0.0.1:51020
JRunConfig Apialloc false

Gotchas

SSL certificates

If you are using SSL sites with name based virtual hosting there is a limitation which is: You can only have one SSL certificate - This works fine if all the sites are under the same domain - i.e. site1.example.com & site2.example.com and you have a wildcard certificate - *.example.com. The reason for this limitation is that when the server sends the SSL cert it doesn't yet know which domain you are looking for as it happens at the negotiation phase. Once the SSL cert is in use though the request proceeds correctly and serves the correct site.

Wildcard sites - *.example.com

Apache supports the * operator for sites which mean any subdomain site will match this virtual host. With name based virtual hosting only the first site on a particular IP address will be able to do this. So it wouldn't work to have *.example1.com and *.example2.com on the same IP address. To get around this you need seperate IP addresses for each group of sites.

Conclusion

Apache configs are not as scary as you think - and the documentation is great. They allow you loads of control of the server, are easy to backup and can be used with version control and can be edited with any editor of choice.

Expand Windows NTFS drive on a vmware machine

We use Vmware Server quite heavily at RedBalloon and it gives us a huge amount of flexibility and scalablity without breaking the budget.

An example of this flexibility is how we dealt with a recent problem where one of the drives on our Domain Controller was too small, but we had space available on the underlying Ubuntu Linux VMware Host.

So the plan is to shut down the server, increase the size of the virtual drive, resize the filesystem and we should be good to go.

BTW - this is not for the faint hearted and if done wrong can hose your system.

Here are the steps:

First of all run a chkdsk on the windows drive you are about to resize from within windows:

chkdsk e:

Then make a backup the disk you are about to resize - it's a virtual disk so we copy the files on the host machine. From the VM directory

sudo mkdir backup
sudo cp myDisk.* backup

Expand the original disk with the vmware virtual disk manager and fix the permissions

sudo vmware-vdiskmanager -x 30GB myDisk.vmdk
sudo chown admin:admin myDisk*

You now have a big disk - but the windows NTFS filesystem is only using the original size of the disk. There is no built in way to resolve this in Window but never mind, Linux comes to the rescue again!

Reboot into a Ubuntu Live CD

Open a terminal and run the following commands to resize the filesystem

This is the most dangerous step - as it's where you can really mess up your system.

sudo fdisk /dev/sdb # insert relevant drive instead of sdb
# Then delete your the relevant partition and recreate a larger one
# Note that it needs to be recreated identically except that the end of the partition is bigger. I.e. it needs the same start point on the disk.

sudo ntfsresize /dev/sdb #Again change as relevant

Reboot and windows will run a chkdsk on the drive, then boot and you are all done.