Daily Archives: January 4, 2016

Use proxy_mod to redirect apache to tomcat

Recently, I moved my legacy blog PersonalPage to newer wordpress on Amazon ec2. WordPress is on apache php. Old peronalpage was wrote on tomcat. They are running on different ports. Today, I configured that I only visit through same port by using mod_proxy. By mod_proxy, all the request www.allenlipeng47.com/PersonalPage will forward to www.allenlipeng47.com:8080/PersonalPage

In httpd, add below at the end of httpd.conf file
LoadModule proxy_module modules/mod_proxy.so
ProxyPass /PersonalPage http://www.allenlipeng47.com:8080/PersonalPage
ProxyPassReverse /PersonalPage http://www.allenlipeng47.com:8080/PersonalPage

In tomcat, add below proxyPort=”80″ at connector 8080 part:
<Connector port=”8080″ protocol=”HTTP/1.1″ proxyPort=”80″ />

Done. After I open my legacy www.allenlipeng47.com/PersonalPage website, it shows successfully.

Remove Duplicate Letters


Given a string which contains only lowercase letters, remove duplicate letters so that every letter appear once and only once. You must make sure your result is the smallest in lexicographical order among all possible results.


Given "bcabc"
Return "abc"

Given "cbacdcbc"
Return "acdb"

Solution. We use a nums[] array to record how many times each letter happen in string. We use a stack to store the result. Then we go through each char ch. If ch already visited, then continue. If not visited, and ch is smaller than stack.top() and it still has stack.top() later(nums[stack.top()] > 0), then we pop stack.top().

check my code on github: link