apache- Setup http proxy to add header to Http Headers

In this post i will guide how to setup http proxy to add header to http headrs. To do that we need following plugin:

  • mod_headers

Make sure you’d intalled two above plugin. Add follow config to httpd.conf (change value as your expectation)

ProxyPass / http://localhost:8080/myapp
ProxyPassReverse / http://localhost:8080/myapp
Header set sample_header "sample_value"
RequestHeader set sample_header "sample_value"

Header will add header to http response
RequestHeader will add header to http request.

This plugin very useful for you to know where the request come from when you have many proxy route to web application
You can read more on mod_header document here

Spring security remember me

Follow the post about Spring Security, in this post I will guide how to implement Spring Security remember me to your spring web application. Remember me is a convenient feature that allow user automatically logged to application without need to enter username and password.

Spring security provide two difference implement of remember me service Token-based remember me and Persistent remember me service Continue reading Spring security remember me

How to configure Apache 2 with Tomcat

Today i will guide how to install and configure apache 2 with tomcat on Centos server using mod_proxy plugin
apache-and-tomcat

Scenario of this configuration:

  • Server A install web server apache and have domain app.devjav.com(this domain already point to server A)
  • Server B install tomcat server listen on port 8080
  • We need allow user access application run on tomcat server in server B through  domain app.devjav.com

Continue reading How to configure Apache 2 with Tomcat

Spring scheduler – cron expression

When working with spring scheduler, you will see we can use cron expression to configure when scheduled task will run. In this post  i will help you to know how cron expression work.

Cron expression is six fields that separate by single space. Below is ordinary of field from left to right with possible values.

Position Name Possible Values Special Character
1 Second 0-59 , / * -
3 Hour 0-23 , / * -
4 Day of month 1-31 , / * – ?
5 Month 1-12 or JAN-DEC , / * -
6 Week day 1-7 or MON-SUN , / * – ?

Note:

  • ,: list possible values
  • / sequence
  • *: every possible values
  • -: rage from two numbers
  • ?: unspecific value

Some examples:

  • 0/5 * * * * *: for every five second
  • * 0-59/2 * * * *: for every two minutes: 0,2,4,8…58
  • * * 2,14 * * MON-FRI: run on 2am and 2 pm from Monday to Friday