I am building a solution where the CMS part of the site (i.e. About US, Contact etc) will be run on Wordpress & the private pages will be a Java-Servlet based stack run on Tomcat 7.

Both of these "apps" have to run on the same server for budget reasons, at least for now.

What I want to know how to make this happen (via configurations, setups etc)? So that whenever users come to public pages they will be served content from Wordpress but for private pages (here I am assuming there will be a URL pattern differentiating this) then it will be served by Tomcat

I am assuming here that I will be using Apache as the server for fronting the wordpress requests. Also it is an Ubuntu 12.04 server.

  • Not sure what the problem is, you can use different port, different ip or a subdomain (cleanest option imho) to differentiate private service. – LinuxDevOps Jun 10 '14 at 14:38
  • @LinuxDevOps If I use different port, then how to make sure that the port number does not show up in the URL? Subdomain looks like a good solution, but then will I have to buy SSL certificates for both main & sub-domain? – Chantz Jun 10 '14 at 14:40

I think the technology you are looking for is a reverse proxy. Configure your tomcat to listen on 8080 and have apache act as a proxy for it using mod_proxy_ajp or similar.

  • +1 we use mod_proxy for this stuff – natxo asenjo Jun 10 '14 at 16:12
  • @lain I tried using mod_proxy_ajp, but it seems that only the HTML is being returned, but all the static assets within it are not getting loaded & returning 404. Here is the vhosts file I have gist.github.com/tankchintan/d8e94f9c0ed983f689cc The path of those static assets uses the original address which is port 80. – Chantz Jun 12 '14 at 0:44
  • Now that you know the technology to use it's your job as a sysadmin to figure out how to make it work surely ? – user9517 Jun 12 '14 at 6:45
  • I was missing the renaming of my war file, to match the context & then updating the context in the ajp:// path. Thanks for helping along! Appreciate it. – Chantz Jun 13 '14 at 1:59

I recently put all together with Quercus (a PHP5 java implementation) building up a single WAR file with the latest wordpress.



Taking @lain's direction I was able to finally resolve the issue by doing couple of things.

  1. Renamed the WAR file in my tomcat, in this case private-pages
  2. In my virtual hosts definition I changed ajp:// to reflect the above change.

Here is virtual hosts file,

<VirtualHost _default_:443>
        ServerAdmin webmaster@localhost
        ServerName localhost:443

        DocumentRoot /var/www

        <Directory /var/www>
        #For Wordpress
                Options FollowSymLinks
                AllowOverride All

        <Proxy *>
                Order deny,allow
                Allow from all

        ProxyPreserveHost On
        ProxyRequests           Off
        ProxyPass               /private-pages       ajp://localhost:8009/private-pages
        ProxyPassReverse        /private-pages       ajp://localhost:8009/private-pages

        <Location /private-pages>
            Order allow,deny
            Allow from all

        SSLEngine on
        SSLProxyEngine On

        SSLCertificateFile      /etc/apache2/ssl/apache.crt
        SSLCertificateKeyFile /etc/apache2/ssl/apache.key


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.