Ajax: load data from same server but different port - ajax

My main web application is on apache, but sometimes I need to import some pages/data from tomcat server running on same machine. Now Ajax doesn't allow me to request data from tomcat due to "Single Origin Policy".
So how can I implement the import of data from tomcat? One solution could be to use iframes. However someone suggested using relative urls. How do I implement that?

Use the Apache Tomcat Connector (mod_jk). This is used to tell Apache that certain resources will be served by Tomcat (much like mod_php/ mod_perl, etc.). Then your requests go to the same server and you get the added bonus of being able to apply all Apache's stuff to your servlets.

Related

Move Confluence to subdomain (no port) on JIRA server, with Tomcat

I'm using both JIRA and Confluence on the same server, running on Windows, using Apache Tomcat.
I have two domains pointing at the server, jira.company.com and confluence.company.com.
JIRA is running fine on port 80 in the Apache Tomcat instance, and I can get to that on the JIRA.company.com domain just fine.
Confluence is currently running on port 8090 on the same machine. What I'm trying to do is get Confluence working on the confluence.company.com domain.
Most of the documentation I can see is about configuring virtual hosts and reverse proxies in httpd.conf, however in Apache Tomcat all I have to work with is the server.xml file.
I understand I can add another host to the JIRA server.xml file to point to a different docBase for Confluence, but I have a feeling this breaks Atlassian's own recommendations found here.
When I add an additional host entry into Confluence's server.xml it's ignored, and the confluence.company.com domain sends me through to JIRA.
I've done some searching and found similar questions but they don't seem to apply to my configuration - they all mention httpd.conf which isn't present on my server.
My questions:
Can I run Confluence on the subdomain by adding an extra entry in JIRA's server.xml? If possible, is this bad?
Is there another way to get my Confluence Apache instance listening on port 80 but on it's own domain name?
I can do all this on IIS with my eyes shut, but in Apache/Tomcat I'm a little lost. Thanks in advance!
Tomcat is not really meant to directly handle incoming requests as usually an Apache or other proxy is put in front of it to hide the ports and provide other useful features you would need for Single Sign On etc. Note that there is a difference between the Apache Webserver, which is commonly only called "Apache" and "Apache Tomcat", which is only an application server made by the Apache Foundation community and named "Tomcat". Tomcat only supports basic webserver functionality.
In any case, you can use the IIS as a webserver and proxy to forward the requests and at the same time hide the ports of the applications. I personally haven't used IIS but Atlassian offers a thorough explanation for the Confluence and/or JIRA integration with IIS as a proxy: https://confluence.atlassian.com/adminjiraserver071/integrating-jira-applications-with-iis-802593039.html
The page covers JIRA for the most part but section 4 also has additional information if you want to hook up both JIRA and Confluence on the same server, which is exactly your use case.

Load Balancing with Tomcat

This may sound a basic question...
But I am new to concept of load balancing and had few questions.
Scenario - I have 3 Tomcat 7 servers which I want to be load balanced.
I read few articles and saw that using Apache HTTP Server one can do this.
There exists a worker.properties file which needs to be defined with the servers you would like to load balance. Now the problem is that this needs to be done before I start the Apache HTTP Server.
Problem - What if I want to add few more Tomcat Servers dynamically without restarting the Apache HTTP Server. Is this possible ?
Regards
Ajax
I spot an interesting article about Tomcat & PAAS: http://www.devx.com/Java/Article/48086
You will probably find what you need in the article. It describes the mechanism to register / unregister a new node in the cluster.
HIH
Apache HTTPD 2.4 supports dynamic reconfiguration of the load balancer. But use the load-balancer proxy module for this, not mod_jk.

Apache install before Tomcat, what is the advantage?

Ive read so often that an Apache Webserver should be installed before an tomcat to achieve better performance. They say. that tomcat can't provide static files as well as the Apache.
I would like to understand how it works in detail. I researched the internet, but I didnt find any good explanation.
A client sends a request
The request goes to the Apache
If the request is for a static file, the Apache gets the static file and gives it back to the client
If the request is for a dynamic file (like jsp), the apache gives the request to the tomcat
the tomcat generates the file
the tomcat gives the response back to the Apache
Apache sends to response to the user
Is that correct??? Or do requests for static files also go to the Tomcat? Then why is Apache needed?
Thanks for clarifying it :-)
Yes you got it pretty much right. Static requests are usually served by Apache and not forwarded to Tomcat server.
You can use mod_jk or mod_proxy_ajp to forward your dynamic requests to Tomcat.
Another advantage of using Apache in front is load bakancing of your traffic.

Reverse Proxy on Windows

I have a web server that responds to a number of different sites on port 80. Currently, IIS does the mapping to various sites via host headers, but I'd like to be able to serve other web apps on port 80 hosted in Jetty or Tomcat. IIS prevents that by grabbing all port 80 traffic.
I basically need a reverse proxy to just change the port number to something that another app stack can listen in on. I was looking into nginx but it seems to not be quite ready for prime time on Windows. Eventually I may set up a Linux box specifically for this, but for now I'm interested in a solution which will run all on the same box.
All I really need is something very light which mostly just matches hostname/port and allows rewriting of the port. Does anyone have any suggestions?
If you are running in IIS 7 or above you can use Application Request Routing for that: http://www.iis.net/download/ApplicationRequestRouting
For IIS 5-6, it looks like Apache Tomcat Connector (JK 1.2) is a clean solution. This is an IIS ISAPI filter which allows IIS to act as a reverse proxy for other web servers. It uses Apache JServ Protocol (AJP) to communicate with the app server actually serving requests. Both Tomcat and Jetty implement AJP. URLs are mapped with regex-like config to a particular AJP server instance.
Overview: http://www.iisadmin.co.uk/?p=40&page=3
IIS Config: http://tomcat.apache.org/connectors-doc/reference/iis.html
Mapping Config: http://tomcat.apache.org/connectors-doc/reference/workers.html
This ISAPI plug-in also works with IIS 7.x, but in that case the Application Request Routing (see marked answer) should be considered as it might work better with non-AJP servers.

WebServices load balancing using Oracle WebCache?

I am using JBoss 5.1.0.GA on Red Hat Linux 4. We have only webservices deployed on this application server as .war files (servlets only, no stateful applications present). As a part of our architecture change for improving scalability, we are planning to have multiple JBoss servers running (may or may not be on different IP's and machines) and have a load balancer in front of them to distribute the load. Some of those I know recommended Oracle WebCache for load balancing.
When I started using it, I am able to load balance between the JBoss home page, i.e., requests for viewing the http://loadbalancer-hostname:8080/ brings up the actual JBoss home pages for both the servers in a round robin fashion.
I am trying to simulate external load on the webservices and started using soapUI plugin for NetBeans to do this. When I import the WSDL using the loadbalancer-hostname, it is imported fine, but when I load test it, the requests always go to the same server. My assumption is : When soapUI imported the WSDL, the actual WSDL file would have its <soap:address location="http://actual-server:8080/...?wsdl">. May be this is causing soapUI to always hit the same server.
My question is does Oracle WebCache perform load balancing for webservices as well ?
Yes it can.
A web service URL is like any other URL to the load balancer.
What's most likely happening in your case is the DNS look up is getting cached within the JDK on the consumer side of the web service.
Within Java, once a DNS is looked up, it caches the IP address via the networkaddress.cache.ttl property in %JRE%\lib\security
See this link for more:
http://www.rgagnon.com/javadetails/java-0445.html

Resources