Configuring Tomcat to communicate through proxy in Localhost - Fiddler - java

Tomcat is running in my localhost on standard 8080 port. When tomcat calls a service (soap/rest) running in the same server, I would like to capture it through fiddler.
Basically, any request that tomcat sends out, should be captured through Fiddler. Currently, it sends out request to another service running the same machine and that service in turn calls Amazon AWS, which I would like to capture as well.
Can anyone help? Note that this is opposite of traditional web request through proxy to the server.
I am open to any other alternatives as well.

Please have a look at How to capture SOAP messages from a Tomcat Java app to an external server? for information on setting the proxy for Tomcat.
The correct JVM parameters should look like: -Dhttps.proxyHost=127.0.0.1 -Dhttps.proxyPort=8888 -DproxySet=true -DproxyHost=127.0.0.1 -DproxyPort=8888

Related

How to make a web service url work on a remote machine?

I have developed a REST based web service that works perfectly on my machine. The URL is
http://localhost:8080/MyRESTProject/resources/welcome/
Obviously, the URL would work only on my machine. What I want is the URL to work on any remote machine. Also, I want the service to run constantly. Is this possible even after I terminate the web service process?
PS: I am using eclipse dynamic web project to build this web service and the OS is windows 7.
Your web service will be available as long as it is being hosted. A web server receives HTTP requests and replies with HTTP responses. How can you expect your web service to continue working if you terminate the server process?
As for your web service being accessible from outside, you will need to know the public IP address of your network. You can search "What is my public IP" on Google search to get your answer.
But you are not done yet, you will need to configure your router/firewall to open up a port on your router and map it to port 8080 on your host.

Java Webservice hitting proxy instead of destination on Apache Tomcat

I have a java webservice running on Apache Tomcat 7.0.39. It receives a message from another server on the same network then tries to send an outgoing message back. This outgoing message is being sent to NAProxy instead of the server it's supposed to.
I've turned off proxy settings in IE and the Java control panel. I've tried adding a ProxyServer variable to the cxf-beans file:
<http-conf:conduit name=".*http-conduit">
<http-conf:client ConnectionTimeout="20000" ReceiveTimeout="30000" ProxyServer=""/>
</http-conf:conduit>
but neither of these things work.
IE can reach the destination service from the outgoing server. I can hit the hosted destination service from the server using SOAPUI, so it's just a problem with the apache service, not the box.
It seems it is defaulting to use the proxy instead of a direct connection. Is there a setting somewhere to turn off proxy use?
Proxy can be set also using system properties http.proxyHost and http.proxyPort. I don't know how your application is being started, but maybe somewhere there are JVM parameters -Dhttp.proxyHost=... -Dhttp.proxyPort=...
Since it is Tomcat, maybe you should check startup file.

Solaris KSSL and a Java web server

I'm trying to setup a Solaris KSSL proxy (http://www.c0t0d0s0.org/archives/5575-Less-known-Solaris-Features-kssl.html) as a frontend to a Jetty web server.
I'm able to make KSSL work with Apache web server so that KSSL redirects all incoming SSL traffic from port 443 into an Apache web server listening on port 28080.
However the same configuration does not work when Jetty is listening on port 28080. I verified that the KSSL requests does not even reach Jetty or at least I cannot see them in the access log. Furthermore even if I set a simple Java class which just listens on a server socket, KSSL cannot redirect requests to it.
My question is what are the pre-requisites from a web server in order to be able to get requests from KSSL ?
Best regards,
Lior
There are 2 very common gotchas when working with kssl.
The first is that the apache listening IP has to be the same
as your ksslcfg command. So if you have Listen 123.123.123.123:28080 in
the httpd.conf file, then you must use a ksslcfg command with the same IP.
You cannot have it listening on ANY (*) and then list an IP in ksslcfg,
or listen on an IP and leave out the IP on ksslcfg. Whatever netstat shows
is listening on port 28080 must match the IP used in ksslcfg
(or don't use the IP it is listening on *)
The second is that you must do the operations in this order:
ksslcfg
restart apache
It doesn't not work if ksslcfg is run without restarting apache afterward.
I've seen many people on the web testing with something like
localhost in their ksslcfg command. It won't work unless you also
had localhost as the Listen IP in the apache configuration.

Not able to access webservice from same network java

My webservice is running on jboss and client is on the tomcat
both client and webservice is running perfect on my local machine.
but if i setup client on another machine, the client program giving an error message 404 not found
I have shared my jboss over network and i am able to access webservice wsdl from another machine using http:192.168.1.26:8080/FalconServer/SearchService?wsdl
I set the same url in Client code.
but it won't work, any help
I wanted to put this as a comment, but i dont seem to find a comment button.
Did you start your jboss binding to your ip address. One way to do that:
run -b

Java EE getting servlet container port

I want to programmatically get the servlet containers port that my Java EE application is deployed on. I assumed there would be something in the JMX beans but I can't seem to find anything.
And before anyone says grab the port from the HttpRequest or HttpResponse it should be noted that this process is running behind the servlet and has no interaction with the Requests or Responses.
One possible "hack" would be to parse the server.xml at runtime and identify the port that is configured.
But looks like there is a way to do it using JMX / MBeans as well.
I happened to have a strong need to extract the tomcat port from request. So that I can compare and tell if the servlet request is from tomcat port http://localhost:8080 or from apache port http://localhost/
By doing this, I can make sure the request only be processed by strictly using tomcat port and rejecting by apache port. This may help setup security configuration that the request would not allow outside world access via apache. tomcat port only available within local network.
The method is to create a tomcat valve (assuming you know what it is) implements org.apache.catalina.valves.ValveBase.
This interface provides org.apache.catalina.connector.Request as an argument.
Per request:
using request.getConnector().getPort() which returns 8080. Then say.
if ( request.getServerPort() != request.getConnector().getPort() ) {
response.getWriter().print("<span>access denied</span>");
} else {
getNext().invoke(request, response);
}

Categories

Resources