步骤
- 停止 Tomcat 服务器。
- 设置配置。配置文件是 <TomcatPath>/bin/setenv.sh。如果该文件不存在,则创建它。
-
添加以下参数,即可更改参数以匹配配置:
CATALINA_OPTS=$CATALINA_OPTS -Dhttp.proxyHost=proxy.server.com # Specify the host name or IP address of your HTTP proxy server. You can use this parameter for http and https host names. CATALINA_OPTS=$CATALINA_OPTS -Dhttp.proxyPort=YourHttpProxyPort # Specify the port number of your proxy server. CATALINA_OPTS=$CATALINA_OPTS -Dhttp.nonProxyHosts="localhost|host.mydomain.com|192.168.0.1" # Specify a list of hosts separated by "|" that do not require access through your proxy server.
例如:CATALINA_OPTS=$CATALINA_OPTS -Dhttp.proxyHost=proxy.server.com CATALINA_OPTS=$CATALINA_OPTS -Dhttp.proxyPort=3128 CATALINA_OPTS=$CATALINA_OPTS -Dhttp.nonProxyHosts="localhost|host.mydomain.com|192.168.0.1"
如果您在使用需要认证的代理,打开<tomcat_path>/WEB-INF/classes/configuration.properties
文件并取消下列各行的注释:- 基于 HTTP 协议的代理:
#http.proxyUser=someuser #http.proxyPassword=somepassword
- 基于 HTTPS 协议的代理:
#https.proxyUser=someuser #https.proxyPassword=somepassword
- 基于 HTTP 协议的代理:
- 重新启动 Tomcat 服务器。