问题
I've been trying the whole day to make Tomcat6 use system proxy settings. Tried various ways, about 200 different Versions of
tomcat6 //US/Tomcat6 ++JvmOptions "-Djava.net.useSystemProxies=true"
I tried to set the property in service.bat
in the "install" section like this (also many similar versions):
...
:foundJvm
echo Using JVM: "%PR_JVM%"
"%EXECUTABLE%" //IS//%SERVICE_NAME% --StartClass org.apache.catalina.startup.Bootstrap --StopClass org.apache.catalina.startup.Bootstrap --StartParams start --StopParams stop --JvmOptions "-Djava.net.useSystemProxies=true"
I tried settings this with the tomcat6w GUI. Not sure if it does anything anyway.
Also tried setting JAVA_HOME
to JRE and JDK. No difference.
Tried setting -Dhttp.proxyHost=proxyhostURL
and -Dhttp.proxyPort=proxyPortNumber
. Those at least seem not to be ignored because the connection then failed (used random local ip and port).
Now the fun fact: I can run it through catalina.bat
, set the parameter there (CATALINA_OPTS=...
) and it works like a charm. So what is that doing there? I would like to have it as a service which would be way more user friendly, but if there's no way to achieve it, I'm willing to consider just throwing catalina.bat
into autorun.
So... did anybody ever get that working? Or does anybody have ideas/advices?
回答1:
Assuming this is on Windows, I found a Registry key under:
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Apache Software Foundation\Procrun 2.0\<app-name>\Parameters\Java
The entry is named Options
of type REG_MULTI_SZ
. This contained all the -D JVM options, one line per option. I added our HTTP/HTTPS proxy name (we're using NTLM authentication proxies)
-Dhttp.proxyHost=proxy.company.local
-Dhttp.proxyPort=8080
-Dhttps.proxyHost=proxy.company.local
-Dhttps.proxyPort=8080
-Dhttp.proxyUser=svc_account
-Dhttp.proxyPassword=svc_Password
来源:https://stackoverflow.com/questions/9809107/tomcat-6-0-35-windows-32b-service-usesystemproxies