Question

What is the basic things to be follow for mapping a tomcat web application to domain?

Hi,

I have a domain from godaddy with running tomcat7 application and that was configured in apache using proxy. Now i would like to move entire thing to tomcat only. I don’t need apache now. How should i create a host in tomcat? Where and where i need to update the newly added domain code in tomcat7?

Can anyone suggest me?

Thanks in advance.

Subscribe
Share

Hi, I already made this… proxy done to my url like… Internally every call from my application i made like https://www.domain.com:8443/app1/methods… even though i was getting insecure to access 8443 of https://www.domain.com:8443/app2/methods this url and it is blocking by the browser. So, now i got the problem due to tomcat of 8443 port has no SSL at my backend application(app2) which is being served as response. Where as the app1 has configured SSL of domain www.domain.com to https://www.domain.com:8443/app1/methods… and https://www.domain.com:8443/app2/ doesn’t have https access. This is what the entire figure out. Is there any way to get rid of this tricky with only one SSL? For my sake i am still using config what you made…

Thanks for being with me…

@jaccs – This is a bit tricky. The error messages you were receiving means you were hitting the Cross-origin resource sharing (CORS) rules of your installation. One method to get around this is to proxy your tomcat application at port 8443 to somewhere in the URL of your web pages, and then all your front end code would need to change to use that proxy.

You’ll have to do research to fit your particular situation, but the overall plan is something like this:

Have fun.

web browser X accesses ==> apache webserver at port 80 which redirects to ==> webserver secure port 443 which uses ==> tomcat webservices API at port 8443

Here’s my simplified guesses of your current stack:

web browser X accesses ==> apache webserver at port 80  which uses ==> tomcat webservice API at port XXXX
 OR
web browser X accesses ==> apache webserver at port 80 which redirects to ==> webserver secure port 443 which uses ==> tomcat webservices API at port XXXX
 OR
web browser X accesses ==> apache webserver at secure port 443 which uses ==> tomcat webservices API at port XXXX

Is one or more of that correct? Can you fill in some of the X’s above, or provide a simplified diagram of your stack?


Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Your apache proxy settings looks a bit off. Save a copy of your existing apache configuration somewhere else (like your home directory), and try modifying your current apache configuration entries to something like this

<VirtualHost *:80>
 ServerName www.domain.com
 ProxyPreserveHost       On
 ProxyRequests   Off
 ProxyPass / http://localhost:8080/domain/
 ProxyPassReverse / http://localhost:8080/domain/
 RewriteEngine on
 RewriteCond %{SERVER_NAME} =www.domain.com
 RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,QSA,R=permanent]
</VirtualHost>

<VirtualHost *:443>
 ProxyPreserveHost On
 ProxyRequests Off
 ProxyPass / http://localhost:8080/domain/
 ProxyPassReverse / http://localhost:8080/domain/
 ServerName www.domain.com
 SSLEngine on
 SSLCertificateFile /home/developer/domain.crt
 SSLCertificateKeyFile /home/developer/domain.key
 SSLCertificateChainFile /home/developer/intermediate.crt
 SSLCACertificateFile /home/developer/ca-bundle.crt
 </VirtualHost>

A few more non-critical notes: the standard location for your SSL certificates should reside on a secure location, like somewhere in /etc. Also, you may want to explicitly add the error and access logging locations in the section shown above.

Hope that works for you.

Tomcat as your primary web server is not recommended since you’ll have a difficult time setting up security arrangements, like setting security certificates for https. Having said that, the quickest way is to disable or remove apache/nginx from listening to port 80, and then configure Tomcat to take over that port.