Does Weblogic 12c server ignore http.proxy* parameters? - java

I'm running Weblogic 12.1.2 on Mac OS X and I have a system wide proxy set in Network Configuration.
I wan't Weblogic to ignore the proxy setting and use direct connection to web services. However, the Weblogic seems to ignore any command line http.proxy* parameters.
I modified startup script to add following parameters:
-Dhttp.nonProxyHosts=* -Dava.net.useSystemProxies=false -Dhttp.proxySet=false
but Weblogic still tries to use proxy to connect to web service.
Anyone experiencing similar behavior? Should I use some specific prefix?
EDIT: Weblogic 12.1.1 seems to ignore proxy settings at all.

I forgot that I must re-set http and https proxy.
The best place to do it is in file setDomainEnv.sh by adding following lines to the bottom:
PROXY_SETTINGS="-Djava.net.useSystemProxies=false -Dhttp.proxyHost=\"\" -Dhttps.proxyHost=\"\" -Dhttp.proxyPort=\"\" -Dhttps.proxyPort=\"\""
export PROXY_SETTINGS

you should set in http.nonProxyHosts
http.nonProxyHosts: a list of hosts that should be reached directly, bypassing the proxy. This is a list of patterns separated by '|'. The patterns may start or end with a '*' for wildcards. Any host matching one of these patterns will be reached through a direct connection instead of through a proxy.
java -Dhttp.nonProxyHosts=”localhost|host.example.com” GetURL

Related

Tomcat Request.getPort() stripping port number

Problem:
I am using Java HttpServeltResponse to call sendRedirect but on a particular deployment the URL port number is not included in the HTTP 302 response message.
Details:
I have an application, which uses spring security to authenticate and redirect on success. The redirection URL provided by me is a relative path.
On redirection the spring framework calls sendRedirect on HttpServletResponse passing in the context path along with the relative URL. For example:
HttpServletResponse.sendRedirect("/MyApp/index.html");
This all works fine when we deploy to tomcat instances on various platforms (Windows/Ubuntu etc). However one of our clients is finding that in their deployment, the redirection port is stripped, for example, if the entry point is:
http://server:8082/MyApp/authenticate
The redirection they get is:
http://server/MyApp/index.html - this page does not exist, as it is missing port 8082
Stepping through the code, I can see that the port is determined by asking the Java Request Object, which seems to be supplied by the Web Application Container (i.e Jetty/Tomcat?). In my dev environment it is org.eclipse.jetty.server.Request.
So is this a tomcat configuration issue? We could replicate the same behaviour using Apache2 ProxyPassReverse, but they assure me they are not running Apache2, and their connection is a direct connection to tomcat.
As I can not replicate this issue anywhere, I am really stuck for an answer. Any help would be very much appreciated.

Tomcat debugging not possible through eclipse

I've made a script called debug.sh and placed it under the bin directory (start it with ./debug.sh) to start Tomcat 8 in debugging mode:
set JPDA_ADDRESS=8000
set JPDA_TRANSPORT=dt_socket
set JAVA_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n
bash catalina.sh jpda start
But if it started, there is now message which says, that Tomcat is listening on port 8000. Also if I type
netstat -nat
there is no application listening on port 8000.
What exact configuration do I have to set, to remote debug my Tomcat 8 server which is running on a specific IP or do I have just a little problem in my script?
This answer has been updated following the comments, I did not understand the problem in the first place.
I guess you have followed that doc: this is about developing Tomcat itself.
I am not sure you are using the proper way to configure the port (I don't know your specific configuration details). In a standard environment, the ports are configured in the server.xml (note that several different ports are used by Tomcat for the different services).
To remotely monitor your server, you should use a JMX client. As far as I know, Eclipse doesn't include one (or at least not one documented) - you could code one as this is a Java specification (JSR262). You have one in a standard Java environement (JConsole). By default, JMX is not enabled on Tomcat. If you need to enable it, the fine way is to follow the doc.
Tomcat JMX monitoring and JConsole are both available in most versions of Tomcat and the Java runtime.
The following exchange seems to be about your problem.

How to configure Apache to redirect subdomains to Tomcat applications

I have a few applications hosted on Tomcat running a machine called test-websites throuhg port 8080. So they are accessible like this:
http://test-websites:8080/app1/
http://test-websites:8080/app2/
...
http://test-websites:8080/appN/
What I need to do is make these applications accessible on my local network by:
http://app1.test-websites/
http://app2.test-websites/
...
http://appN.test-websites/
As I add new applications to Tomcat's webapps folder, I want them to be automatically available using the same subdomain pattern.
So I thought using Apache in front of Tomcat to make the URL rewriting would be a good idea, but so far I have not been able to configure the virtual host on Apache to make this redirect. I installed apache2 on port 80 and I see the default "It Works!" apache page when I access http://test-websites/, but I couldn't find how to make the redirects to the apps in the Tomcat following the format above.
I have searched for over 4 hours and didn't get an answer for this use case.. any help us much appreciated!
Thank you!
Eduardo
First you need to add a DNS entry for app1.test-websites, app2.test-websites,.. such that it points to test-websites. Generally CNAME entry works best in this case. If you only need the URLs to resolve on your local machine (for testing purpose), you can just update your /etc/hosts or C:\windows\system32\drivers\etc\hosts file. Otherwise you need to figure out how your company's network is setup and change the DNS entry (if it's a Windows domain network, normally there's a DNS service on the domain controller. On some smaller network you have to configure it on the router).
Next, the quickest way to achieve this is to not use apache2 to front it, bust simply have tomcat listening on port 80. You can setup virtual host on tomcat such that it serves different web-app depending on the URL requested.

How can I know if tomcat is running behind Apache?

In production we run tomcat behind apache, in development bare tomcat.
How can I know inside the Servlet class if it is running behind apache or not?
This depends on how your Apache is talking to Tomcat.
If it's connected via HTTP (mod_proxy), you can check request.getRemoteAddr(). It will be the IP of the Apache, probably your internal IP. You can also check "Via" header to see if Apache is there.
If it's connected via AJP (mod_jk/mod_proxy_ajp), you can check request.getLocalPort() to see if it's the port of your JK connector.
If this is to distinguish between development and production environment, then you will probably be better off by having this completely under your control instead of ad-hoc guessing (which will eventually break).
This could be "Is feature X set in JNDI?" or "Is property foo.bar set in c:/ourproject.properties". You should not rely on artifacts like "is class X loaded from a file or found inside a jar" (since that will break if you change application servers) or "Is http header line X present" since that is out of your control plus it may break if somebody else is using Apache as a frontend accellerator.
So, explicit configuration - it can be done quite easily :)

Weird Tomcat and Axis Webservice behaviour

I have a simple web service deployed on tomcat using Apache Axis.
If i access the webservice as http://localhost:8080/webservices/TransactionService i see the usual message
TransactionService
Hi there, this is an AXIS service!
Perhaps there will be a form for invoking the service here...
showing that the web service is available and ready for use.
However if i access it as http://10.0.0.1:8080/webservices/TransactionService (10.0.0.1 is the actual IP of the machine. I'm accessing it on the same machine as above, machine hosting tomcat) i get:
HTTP Status 404 - /webservices/TransactionService
--------------------------------------------------------------------------------
type: Status report
message: /webservices/TransactionService
description: The requested resource (/webservices/TransactionService) is not available.
--------------------------------------------------------------------------------
Apache Tomcat/5.5
There is nothing in the tomcat logs
If i try deploying on Jetty it all works fine.
Is there any explanation for this? Any pointers most welcome.
Tomcat can listen on different hostnames/IPs in a different way. Specifically, every host/IP can have its own work directory:
<Host name="localhost" workDir="/workdir">
...
</Host>
Application deployed to one workdir won't be available to a host with another workdir.
Check your configuration.
UPDATE: if name is specified as name, not IP, check that that name is resolved to 10.* address too.
Also, one of the hosts is default. It responds to all requests now matter what host they are targeted too, if there is no specific Host. For your setup you may want to leave only that one active.
I don't think a change to Tomcat configuration is the answer. I don't have to do such a thing to use my local IP address or localhost.
Could it be as simple as an addition to your hosts file? I've got mine in c:/windows/system32/drivers/etc/hosts, and there's an entry for "127.0.0.1 localhost" in it.

Categories