Serve java application on port 8080 as default and blog.mydomain on port 80

April 16, 2014 5.2k views
Hi. My full application is a mix of a Wordpress blog and a Java application. I'm running Apache and Apache Tomcat on the same droplet. In this way, if I try http://mydomain.com it runs my Wordpress blog, and if I try http://mydomain.com:8080 it runs my Java application. Both applications are running fine. But what I need is: - http://mydomain.com runs the Java application; - http://blog.mydomain.com runs the Wordpress blog; Is there anyway to do that with DNS or a virtual server? I'm very confused of how do I configure my Apache server to do that. Thanks a lot.
6 Answers
You can't setup apache and tomcat both on port 80

But you can setup both domain on apache with
mydomain.com proxying localhost:8080

The following command should be enough to to enable mod_proxy (ubuntu)
sudo a2enmod proxy

Then change your site config file to something like this:

Listen 80

ServerName mydomain.com

ProxyRequests Off


Order Deny,Allow
Allow from all


ProxyPass / http://localhost:8080/
ProxyPassReverse / http://localhost:8080/



blog.mydomain.com's configs ...


You have to install & enable mod_proxy
Listen 80
< VirtualHost *:80>
ServerName mydomain.com

ProxyRequests Off

< Proxy *>
Order Deny,Allow
Allow from all
< /Proxy>

ProxyPass / http://localhost:8080/
ProxyPassReverse / http://localhost:8080/
< /Virtualhost>

Those < > tag just got eaten ...
Thanks a lot! I'm almost there!

The blog.mydomain.com is working fine!! So, it's 50% success!

But the www.mydomain.com is returning this:

--

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, [no address given] and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

Apache/2.2.22 (Ubuntu) Server at www.consuporteconsultoria.com.br Port 80

--

Is there anything missing?
Is there any output in /var/log/apache2/error.log
No, but I made it.

For some reason I had to execute this:

a2enmod proxy_http

Now it's working.

Thanks to you all.

hello!

in which file you add the configurations?

regards

Have another answer? Share your knowledge.