public class HttpProxyServlet
You can use a set of regular expressions to restrict the list of URLs that this servlet will proxy to. You can specify these win web.xml using the rules
init-param or in a separate file. See the rules
and rulesFile
javadoc below. If no rules are specified, this filter will proxy to any URL requested by the client. If at least one rule is specified, then any URLs not matching the set of rules is disallowed.
Modifier and Type | Field and Description |
---|---|
boolean | acceptInvalidAndExpiredSSLCertificates If set to true, the proxy will accept invalid and expired SSL certificates from the proxied URL. |
java.lang.String | proxyHost If outbound HTTP requests from this proxy must go through a proxy, you can set the hostname of the proxy server via this parameter. |
int | proxyPort If outbound HTTP requests from this proxy must go through a proxy, you can set the port of the proxy server via this parameter. |
protected java.util.List | rules You can specify rules defining the set of URLs proxyable by this servlet inline in web.xml. |
java.lang.String | rulesFile Specifies path to a file that contains a set of regexp rules that constrain what URLs this servlet will proxy to. |
int | urlCacheSize Specifies the size of the URLCache. |
boolean | useURLCache This parameter controls whether the URLCache is enabled or not. |
public java.lang.String proxyHost
If the JVM executing this servlet can make direct HTTP connections to the relevant hosts, leave this parameter unset.
public java.lang.String rulesFile
var rules = [ "match:#http://www.slashdot.org/#", ];Note: The rulesFile path is treated as relative to webRoot.
HttpProxyServlet.rules
public boolean useURLCache
rulesFile
, the URL Cache will cache the result of the application of relevant rules for any given URL. The URL Cache drastically speeds up subsequent rule applications at the cost of memory. Note: the cache is automatically disabled if there are no rules to apply. Performance: The URL cache is an LRU Map. If you're using this servlet on a large-scale site with a lot of unique URLs, you may want to tune its size via the urlCacheSize
parameter to balance between memory usage and performance.
HttpProxyServlet.urlCacheSize
public int urlCacheSize
protected java.util.List rules
rules
init-param of this servlet. For example: <servlet> <servlet-name>HttpProxyServlet</servlet-name> <servlet-class>com.isomorphic.servlet.HttpProxyServlet</servlet-class> <init-param> <param-name>rules</param-name> <param-value> match:|http://www.slashdot.org/| </param-value> </init-param> </servlet>Each rule consists of a type (either "match:" or "block:") followed by a regular expression. Each URL that is sent to the servlet for proxying is compared against the list of rules, and the first one that applies is used. This allows you to, for example, block certain URLs within a domain that is otherwise permitted. NOTE: The presence of rules implies that a restriction is required, so the servlet will block any URL that does not match a "match:"-type rule, as well as any URL that explicitly matches a "block:"-type rule. If you want a completely open proxy (ie, no restrictions on the URLs that can be proxied), leave rules unspecified. If you want an arrangement whereby you block certain URL patterns and allow all others through, specify a catch-all as your last rule - something like
"match:|http:/|"
HttpProxyServlet.rulesFile
public boolean acceptInvalidAndExpiredSSLCertificates
public int proxyPort
If the JVM executing this servlet can make direct HTTP connections to the relevant hosts, leave this parameter unset.