I am using dedicated server. I have hosted different HTML, PHP and wordpress websites on this server those are working perfectly.
Now I want to deploy java web application on this server. So I have installed Apache tomcat server on another port. So now I want to know how I can handle request directly from domain name to tomcat apache server.
Along with this I want to know how I can deploy multiple web applications on single tomcat. I want to know configuration to call different WAR files from tomcat.
Thank you in advance for your support.
You can use Apache as reverse proxy with the mod_proxy plugin: http://httpd.apache.org/docs/2.2/mod/mod_proxy.html
Therefore, you can handle all HTTP requests with Apache, specifying which requests shall be redirected to the Java web app in Apache Tomcat - port 8080.
Easiest way is to set up a HTTP server (apache, nginx, etc.) as a reverse proxy. Then you can map different domains to different contexts, for example:
www.domain.com -> localhost:8080/main/
www.otherdomain.com -> localhost:8080/othermain/
subdomain.domain.com -> localhost:8080/anotherwar/
For example with Nginx it would be done with a ProxyPass directive. Other HTTP servers have their own respective mechanisms.
Related
I have a company application deployed on Tomcat 8 and another application making request to an Apache server that uses AJP ` protocol to access the application. I am new to AJP. I have created an AWS infrastructure using containers with the mentioned application (as an alternative to the described above). The problem is I want to avoid using Apache and use Amazon's ALB (application load balancer) and so far it's working, except the AJP request. The problem I am having is that when not using Apache, I do not need to use AJP anymore and I want to replace it with HTTPS. Will enabling the HTTPS connector in Tomcat do the trick? The lines in Apache configuration are:
ProxyPass /pmaddon-a ajp://*.*.*.*:8009/pmaddon-a
ProxyPassReverse /pmaddon-a ajp://*.*.*.*:8009/pmaddon-a
To sum up, if I skip the Apache server and call Tomcat directly with HTTPS (with enabled HTTPS connector of course) will it have the same result as using the AJP connector as I am now?
I understand what you want to do is:
Access you application directly using the TOMCAT connector
Remove the APACHE in front and its AJP communication with TOMCAT
This is possible to do, perhaps you need to adapt that other application (the one that calls apache) to point to the URL that arrives to the TOMCAT connector.
If the question is if you will have the same result:
I understand yes. AJP and HTTP both serve the same content, it's just a different protocol.
You didnt explain if you have HA therefore I did not enter that topic.
AJP is very similar to http/https except it is a binary protocol from Apache (Apache Jserv Protocol) but it is better performant since it size is almost 1/5 of the http/https.
It is widely being used with reverse proxy web server where webserver talk to application server using AJB.
You don't need to stick with AJP if you are directly connecting to Tomcat connector
I have a fully functional java application(with .jar extension) that can be hosted on a server.
I have a front end website(php) that needs to accesses that application and provide the resultant data that comes out of the application.
What is the best way to do that ? Or am I missing some logic in here?
as of now the app is built as a mac application with a GUI interface where the user has to get the application installed on their workstation. Thus, deciding to move the app to server and provide an unique website where the frontend can access the app hosted on the server
You need to turn your java application to rest service, if you want to get data from java application for your frontend application. If your app's architecture is well design it will not be a big deal.
If you already have a front-end site running PHP, you are likely either running apache or nginx.
Using either, you can configure a proxy for a specific URL, to be forwarded to the application, i.e.
curl http://example.com
> serve /www/example.com/index.php
curl http://example.com/api/abc
> serve http://127.0.0.1:8080/abc
In your apache config file, assuming that once started, your jar file binds to port 8080.
ProxyPass /api http://127.0.0.1:8080/
ProxyPassReverse /api http://127.0.0.1:8080/
I have a web socket server implementation using Netty (say listening on port 8081) and a separate Spring web application running in Tomcat (running in port 80).
I would like to somehow forward all request coming to localhost:80/Websocket to my Netty server on port 8081. Is this possible at all. since Tomcat and spring is build on top of http protocol, idk how this would be possible.
All I wanted to do is enable server push using websocket from my existing spring web app. Any suggestions?
The easiest way would probably be to put an nginx server up front and have it forward requests to /Websockets, however because Websockets is not Http 1.0 you can't use normal ProxyPass directives but according to http://www.letseehere.com/reverse-proxy-web-sockets it's possible via a special plugin
Take a look at the following 2 links which show how to have netty configured using spring. I have done it in grails wherin a netty socket server is running within tomcat, listening on a particular port for binary packets(not http)
link1
link2
Why not just use the WebSocket support in the latest Tomcat (7.0.27)?
Netty can handle HTTP. E.g. http://static.netty.io/3.5/xref/org/jboss/netty/example/http/snoop/package-summary.html
I have an Amazon ELB for my domain www.example.com. At the moment there is one instance behind the ELB running a web app on JBoss 6.0. I want to be able to redirect the user from and to http and https depending on the path. There are three paths only that require https and the other paths should only be accessed through http. I am able to do the redirect to https for the three paths (using web.xml) but not the redirection back to http for the other paths.
I am not using the apache server in front of JBoss so I want to achieve everything through plain Java and JBoss. I want to either use the web.xml or the urlrewritefilter but preferably not both.
Any advice would be greatly appreciated.
Regards
You can use the JBoss official rewrite module which lets you use Apache style rewrite syntax in a rewrite.properties file.
We currently use JBoss 5.1 as the application server and my application is mounted on http://<host>:<port>/<myapp>. Images are rendered via the following mount point
http://<host>:<port>/<myapp>/img?id=<image-id>
Currently the servlet rendering image is present as part of the application, but I have re-factored this code to run on a tomcat server.
How should I re-direct all http requests to http://<host>:<port>/<myapp>/img?id=<image-id> a tomcat instance (e.g. http://<tomcat-host>:<tomcat-port>/img?id=<image-id>)
Where should I put this re-direction rule?
Note:Should I introduce a apache http server in front of jboss server to achieve this? Is there a simpler way to configure this in a dev environment?
One way I have seen these kinds of things handled is to host images and other static resources at the ROOT context level on an Apache web server. In this way you can host multiple web applications at various other context levels on the same server and port and they can all benefit from shared static resources.
Another advantage to this approach is that your Apache web server can help offset some load off of your production environment.