Archive for February, 2014

Preserve Session IDs of Tomcat cluster behind Apache reverse proxy / Sticky sessions with mod_proxy and Tomcat

Wednesday, February 26th, 2014

apache_and_tomcat_merged_logo_prevent_sticky_sessions
Having a combination of Apache webservice Reverse Proxy to redirect invisibly traffic to a number of Tomcat server positioned in a DMZ is a classic task in big companies Corporate world.
Hence if you work for company like IBM or HP sooner or later you will need to configure Apache Webserver cluster with few running Jakarta Tomcat Application servers behind. Scenario with necessity to access a java based application via Tomcat which requires logging (authentication) relaying on establishing and keeping a session ID is probably one of the most common ones and if you do it for first time you will probably end up with Session ID issues.  Session ID issues are hard to capture at first as on first glimpse application will seem to be working but users will have to re-login all the time even though the programmers might have coded for a session to expiry in 30 minutes or so.

… I mean not having configured Session ID prevention to Tomcats will cause random authentication session expiries and users using the Tomcat app will be unable to normally access below application with authenticated credentials. The solution to these is known under term "Sticky sessions"
To configure Sticky sessions you need to already have configured Apache/s with following minimum configuration:

  • enabled mod_proxy, proxy_balancer_module, proxy_http_module and or mod_proxy_ajp (in Apache config)

  LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
LoadModule proxy_http_module modules/mod_proxy_http.so

  • And configured and tested Tomcats running an Application reachable via AJP protocol

Below example assumes there is Reverse Proxy Load Balancer Apache which has to forward all traffic to 2 tomcats. The config can easily be extended for as many as necessary by adding more BalancerMembers.

In Apache webserver (apache2.conf / httpd.conf) you need to have JSESSIONID configured. These JSESSIONID is going to be appended to each client request from Reverse Proxy to each of Tomcat servers with value opened once on authentication to first Tomcat node to each of the other ones.

<Proxy balancer://mycluster>
BalancerMember ajp://10.16.166.53:11010/ route=delivery1
BalancerMember ajp://10.16.166.66:11010/ route=delivery2
</Proxy>

ProxyRequests Off
ProxyPass / balancer://mycluster/ stickysession=JSESSIONID
ProxyPassReverse / balancer://mycluster/

The two variables route=delivery1 and route=delivery2 are routed to hosts identificators that also has to be present in Tomcat server configurations
In Tomcat App server First Node (server.xml)

<Engine name="Catalina" defaultHost="localhost" jvmRoute="delivery1">

In Tomcat App server Second Node (server.xml)

<Engine name="Catalina" defaultHost="localhost" jvmRoute="delivery2">

Once Sticky Sessions are configured it is useful to be able to track they work fine this is possible through logging each of established JESSSIONIDs, to do so add in httpd.conf

LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"\"%{JSESSIONID}C\"" combined

After modifications restart Apache and Tomcat to load new configs. In Apache access.log the proof should be the proof that sessions are preserved via JSESSIONID, there should be logs like:
 

127.0.0.1 - - [18/Sep/2013:10:02:02 +0800] "POST /examples/servlets/servlet/RequestParamExample HTTP/1.1" 200 662 "http://localhost/examples/servlets/servlet/RequestParamExample" "Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130807 Firefox/17.0""B80557A1D9B48EC1D73CF8C7482B7D46.server2"

127.0.0.1 - - [18/Sep/2013:10:02:06 +0800] "GET /examples/servlets/servlet/RequestInfoExample HTTP/1.1" 200 693 "http://localhost/examples/servlets/" "Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130807 Firefox/17.0""B80557A1D9B48EC1D73CF8C7482B7D46.server2"

That should solve problems with mysterious session expiries 🙂

Trip to Ruen Monastery Saint John of Rila – The birthplace of a saint, a God piece of Heaven beauty on earth

Tuesday, February 25th, 2014

ruenski_monastery-beautiful-mountain-view-near-birthplace-of-a-saint

Last Saturday me and my wife Svetlana together with a Christian friend family (Tsvetomir and Dimitrina with their < 2 years old boy – Boris) went to a small 1 day pilgrimage trip to Ruen Monastery – (Ruenski manastery). The holy cloister is situated very near Skrino village, the birth village of greatest Bulgarian saint saint John of Rila. The village is located about 90 km from Sofia and is very near to town of Boboshevo. To reach Ruen Monastery when coming from Sofia, the traveller has to move in direction of "Kulata / (The Tower)" and to pass the village of Djerman and Usoika. Then before entering the village of Skrino there is a 5 km steep car road leading to the monastery.

ruenski_manastir_near_sightview

Saint John of Rila lived in Skrino until his twenties and due to Christian tradition he accepted monkhood in the nearby monastery next to Skrino and a bit later started a hermit life dwelling himself in his first hermit cave situated near Skrino. The Cave of hermit dwelling of Saint John of Rila is now situated about 200 meters from Ruen Monastery and represents a tiny cave encraved in a rock. The rock is so small that maximum of 2 people can be in cave together. It is amazing how a man could live in such a small space.

hermit_cave_of_saint_John_of_Rila_near-his-birthplace
 

Current Ruen monastery Church is recently rebuild in 1995 and the rest of monastic buildings are completed in y. 2002, but according to history it is known a monastery was existent on same place known in medieval times under name "The Holy Father" in  XV century.

Veneration to Saint John of Rila was so high in mid centuries that obviously people recognized Saint John of Rila among the greatest saints.

The nature view near monastery is breath taking .. On the road to it there is Struma river the monastery itself is situated in Vlahina mountain from it there is a sightview of part of Rila mountain.

piece-of-heaven-on-earth-near-ruenski-monastir

Near the monastery buildings there are two paths one leading to the Cave of Hermitage of Saint John of Rila and another one leading to a place with a Cross visible from throughout the region.

the-cross-on-top-of-mountain-ruenski-monastery

The monastery though being among the newest rebuilded ones in Bulgaria has already 3 saint holy relics, one of which is Holy relics from Saint George the Victorious. We had the blessings by God's grace to also meet RuenAbbot Father Ioan (John). We asked the father how many monks are inhabiting the monastery just to get the humorous answer that half of the inhabitants are present (meaning currently in the monastery there are only 2 monks). Fatehr John was evidently very young kindhearted  person  probably in his 30s. He was quite hospitable and invited us for tea and cookies in the small monastic dining room. We had quite a few spiritual talks and spoke on hardship of being a monk in nowadays confused world.

We were send with the Father's blessings and a gift – an icon of saint John of Rila and a book with the history of the monastery from ancient times to now – the book included also the Testament of Saint John of Rila

On our way back before entering Boboshevo we stopped to see and pray near an ancient Church from the 5th century consecrated under saint Theodor (Stratilat) – a Christian martyr saint from the 4th century who lived near Black Sea.

church-saint-Theodor-stratilat-church-5th-century

The Church is an unique Cultural monument as it contains wall patings probably dating back to at least 10th century or even earlier.

sv-teodor-cyrkva-5-vek-bylgaria

Thanks God the weather was quite warm for the Winter season leaving impression Spring has come 🙂

Useful VIM editor tip colorscheme evening – make your configurations look brighter in VI

Monday, February 24th, 2014

I just learned about cool VIM option from a collegue:

:colorscheme evening

What it does it makes configurations in vim edit look brighter like you seen in below screenshots.

– Before :colorscheme evening vim command

colorscheme_vim-linux-editor-options-screenshot

– After :colorscheme evening

colorscheme2_vim-linux-editor-options-screenshot

The option is really useful as often editing a config in vim on a random server is too dark and in order to read the config you have to strain your eyes in long term leading to eye damage.

Any other useful vim options, you use daily?

SL Animated console train for your Linux – useless commans to cheer you up when you mistype ls

Tuesday, February 18th, 2014

sl-cool-program-to-cheer-you-up-when-you-make-a-mistake-on-linux-console

Some time ago I blogged about how to make your sysadmin more enjoyable with figlet and toilet console ASCII art text generators
Besides toilet and figlet another cool entertainment proggie is cowsay. On my home Linux router I use cowsay together with a tiny shell script to generate me a random Cow Ascii Art fun picture each time I login to my Linux. cowrand is set to run for my user through ~/.bashrc.

cowsay print cheerful pictures on your linux console / terminal login how to

In the spirit of ascii art fun arts today I've stumbled on another cool  and uselesss few kilobytes program called "SL". SL is very simple all it does is it cheers up you by displaying a an animated train going through the screen once you type by mistake "sl" instead of ls (list command).
To enjoy it on debian based distributions install it with apt:

# apt-get install --yes sl

SL 's name is a playful joke itself as well it stands for Steam Locomotive.

To get some more ASCII art fun, try telnetting to  towel.blinkenlights.nl – There is a synthesised ASCII Art text version video of Star Wars – Episode IV

# telnet towel.blinkenlights.nl

watch all star_wars episode 1 in ascii art video

If you know other cool ASCII art animation scripts / ASCII art games or anything related to ASCII art for Linux / Windows, please drop me a comment.
 

How to change Outlook Signature – modify and delete Microsoft Outlook email signatures

Monday, February 17th, 2014

I'm using Mozilla Thunderbird over the last 5 years in my life. Just now in my new job place in Hewlett Packard, in order to have well functional mail (with exchange server) – I started using Microsoft Outlook.
Logically a little while after I started my work I have to update my Outlook E-mail signature to reflect my contact details (job position title, email, stand-alone / mobile phone, office address etc.). As of moment of writting I'm using Microsoft Outlook 14.0.6123.5001 (32 bit) part of Microsoft Office Professional Plus 2010.

Its a kind of irony that I had to use Microsoft products after all these years trying my best to avoid using Microsoft technologies but heh, this is life … Though this article will be a bit trivial I decided to blog it because already I had to change email signature for a 3rd time over the last 3 months and every now and then after a month time I tend to forget how I did it last time.

Here is how I changed Email Signature in Outlook:

1. Click on "New-Email" (located below File menu)

2. Click on "Insert" (menu tab)

3. Click on "Signature"

microsoft-outlook-pop3-mail-client-change-signature-screenshot

4. Click on "New" button

As you see Outlook is written in very intelligent manner 🙂
It is possible to have more than one signature and change them every now and then (I guess that's made for Schizophrenic people who like changing their signature a couple of times a day accepting different personalities 🙂 🙂 🙂
For already existing signatures just edit the old one – click on Edit Signature

microsoft-outlook-exchange-how-to-change-email-signature
http://www.clarion.edu/273437/
 

  • Rename Signatures:

        Perform steps 1-4 in ('Create Signatures') except click "Rename button instead of 'New' and begin typing new name.

  • Delete Signatures:

        Perform steps 1-4 in ('Create Signatures') except click 'Delete" button instead of 'New'.

  • Modify Signatures:

        Highlight signature name you wish to modify under

  1. "Select Signature to Edit" then modify signature.

  2. Click "Save" button to save any signature changes made.

Linux: Rename all files extension from upper to lower cases

Friday, February 14th, 2014

Lets say you're an admin involved in webhosting and due to a programmer's mistake, you end up with directory full with files with extension in upper cases but for actual version of website (all pictures are red only in lower cases), hence would like to transform these to lower cases.
To give an example, to illustrate what I mean, lets say you have in a directory files like;

filename.JPG, picture.PNG, new-picture.GIF

and you would like all files to be renamed to lower extension characters, i.e.:

filename.jpg, picture.png, new-picture.gif.
 

# find . -name '*.*' -exec sh -c 'a=$(echo {} | sed -r "s/([^.]*)\$/\L\1/"); [ "$a" != "{}" ] && mv "{}" "$a" ' \;

That's all enjoy 🙂

I work for money if you want loyalty hire a dog – thinking that can solve your internal workplace (dilemmas) issues :)

Wednesday, February 12th, 2014

I-work-for-money-if-you-want-loyalty-hire-a-dog

I WORK FOR MONEY IF YOU WANT LOYALTY – HIRE A DOG!

I was told about those picture few months ago by a friend (Ivan Pushkaroff – Pushi) while we were drinking beer together in  (Delfincheto – a pub more known among people under the name "Ribkata (The Fish)" – A Metal Music pub in Studentski Grad (Sofia's Student City). By the way if you're in Sofia and near "Studentski Grad" be sure to drop by there – they serve great and always fresh fish also for ex-metal heads for me it is always nice to get some memories about  "the good old metal years"

when I tried to complain how difficult it is for me on my job place. I'm a quite sensitive person and a perfectionist and always try to do a great job. Often however there are many obstacles to do your job in right way (as you depend on so many bureaucracy and external people that even if you do your best someone else can mix it up and screw all your effort by not doing his part of the job. The failure of project or Task due to inadeaquacy of someone else involved to do his job right can leave you with a feeling that you have failed even though it is completely not your fault. As these days I'm quite stressed on my job and I have to work on a lot of badly designed projects (and improperly) assigned tasks – yes in big companies it is like these "the right hand doesn't know what the left one is doing". I remembered my dear friend advice to not take it seriously or personally and decided to put these funny picture in hope that these will help me and others to deal with situation of hardships in job in a humorous way After all I'm just a mercenary and I'm doing my best right now in my job at HP … I work for money if they expect higher degree of loyalty let them hire a dog 🙂

Evening service and Holy Liturgy in Russian Church st. Nicolas and marriage preparations

Wednesday, February 5th, 2014

St-nicolas-russian-church-sofia-bulgaria

Last Saturday evening I and my future wife Svetlana went to get train tickets (Sofia Dobrich), cause next week me and Svetlana will be travelling to Dobrich. Afterwards we went to Russian Church in center of Sofia – St. Nicolas for the evening service and confessed. The evening service was led by Archimandrite Philip who is currently Russian Church's prior.

archimandrite-Philip-russian-church-in-Bulgaria-prior

At the end of Church service there was an oilment, as always being on a Russian Holy Liturgy is astonishing experience. On Sunday morning 2nd February we were in Russian Church again for the Russian Liturgy and we took the holy sacraments as it is proper (according to Orthodox Church tradition the marrying couple should confess and receive the sacraments before marrying in Church). After Church service we went to Church crypt to venerate holy relics of Archimandrate Seraphim Sobolev. A big thing is happening in my life nowdays as I will have marriage this week  on Friday 7-th of February:)

We prepared so far almost everything for marriage. My parents helped with finding a marriage resturant and finding musicians for post marriage restaurant celebration. We also travelled to Asenovgrad to look for Svetlana's  wedding dress and we got one  I bough a marriage suit 2 weeks back and we ordered a marriage rings. There is already agreement with a priest father Vasilij – who will merry us in Church St. Trinity this Friday. Father Vasilij serves in Church "Dormition of Virgin Mary" in Kavarna . We choose father Vasilij to make the Marriage vows for the reason he is nativily Russian speaking (like Svetlana) plus the father is a good example of a true Christian priest. Today the parents of Svetlana (mama Vera and papa Alexander) arrived in the airport in Varna for the marriage (thanks God they had safe flight). Sunday night I send Svetlana to Train Station here in Sofia to make latest preparations for marriage. I will be travelling to Dobrich on Wednesday night 1 day before marriage. The rest of things happening around are not so interesting. In y job in HP work is complicated as usual. On my job I'm learning HPSM (HP Service Manager) and how to open new Changes in system and that's mostly my life these days. When I have time I'm playing OpenTyrian and a couple of nice arcade games on my ZTE Android mobile phone and reading some saint livings on mobile.
 

 

VIM and VI UNIX text editor syntax highlighting and howto add remove code auto indent

Tuesday, February 4th, 2014

vim-vi-linux-text-editor-logo-vim-highlighting how to turn vim syntax highlighting on linux

For my daily system administration job I have to login to many SuSE Linux servers and do various configugration edits.
The systems are configured in different ways and the only text editors available across all servers I can use are VI and VIM (VI Improved).

As I usually had to edit configuration files and scripts and I'm on SSH color terminal its rather annoying that on some of the servers opening a file with VIM is not displayed with SYNTAX HIGHLIGHTING. Not having syntax highlighting is ugly and makes editting ugly and unreadable.
Thus it is useful to enable VI syntax highlighting straight into the file being editted. I suspect many novice sysadmins might not know how to turn syntax highlighting in vi so here is how.
 

Turn Syntax Highlighting in VIM

 

1. Open file with vim lets say Apache configuration

# vim /etc/apache2/apache2.conf

2. Press (Esc) Escape and ":" from kbd and then type in syntax on

:syntax on

vim-syntax-highlighting-howto-syntax-on-picture-screenshot-apache-config

To Turn On / Off VI Syntax Highlighting permanent add ":syntax on"
into ~/.vimrc

~/.vimrc file is red automatically on VIM start, so right after :syntax on is appended in it on relaunch vim will start showing colorfully.

Enjoy ! 🙂