Timeout | |
---|---|
Load Balancer |
Copy this in your proxy-webobjects.conf file for your Apache 2.x WebServer:
More proxy pass parameters are described here.
If you run your application on different machines be shure your applications use differen ports!
Don't forget to remove mod_webobjects.so and your old webobjects.conf.
<IfModule proxy_module> # Turn Forward Proxy off ProxyRequests Off # We want all previous proxy routes ProxyVia Full # Just in case: Deny proxy access <Proxy *> Order deny,allow Deny from none Allow from localhost </Proxy> # Balancer-manager: Allowed only from localhost <Location /balancer-manager> SetHandler balancer-manager Order deny,allow Deny from none Allow from localhost </Location> # Include conf/extra/proxy-webobjects.conf # Mac OSX -> # Include /private/etc/apache2/extra/proxy-webobjects.conf </IfModule>
public Application() { super(); ... NSNotificationCenter.defaultCenter().addObserver(this, new NSSelector("addBalancerRouteCookieByNotification", new Class[] { NSNotification.class }), WORequestHandler.DidHandleRequestNotification, null); } private String _proxyBalancerRoute = null; private String _proxyBalancerCookieName = null; private String _proxyBalancerCookiePath = null; public void addBalancerRouteCookieByNotification(NSNotification notification) { if (notification.object() instanceof WOContext) { addBalancerRouteCookie((WOContext) notification.object()); } } public void addBalancerRouteCookie(WOContext context) { if (context != null && context.request() != null && context.response() != null) { if (_proxyBalancerRoute == null) { _proxyBalancerRoute = (name() + "_" + port().toString()).toLowerCase(); _proxyBalancerRoute = "." + _proxyBalancerRoute.replace('.', '_'); } if (_proxyBalancerCookieName == null) { _proxyBalancerCookieName = ("routeid_" + name()).toLowerCase(); _proxyBalancerCookieName = _proxyBalancerCookieName.replace('.', '_'); } if (_proxyBalancerCookiePath == null) { _proxyBalancerCookiePath = (System.getProperty("FixCookiePath") != null) ? System.getProperty("FixCookiePath") : "/"; } } WOCookie cookie = new WOCookie(_proxyBalancerCookieName, _proxyBalancerRoute, _proxyBalancerCookiePath, null, -1, context.request().isSecure(), true); cookie.setExpires(null); context.response().addCookie(cookie); }
public static String clientIP(WORequest request) { Object ipAddress = request.headerForKey("x-forwarded-for"); if (ipAddress != null && ipAddress.toString().length() > 0) { ipAddress = StringUtils.split(ipAddress.toString(), ',')[0]; } if (ipAddress == null) { ipAddress = request._remoteAddress(); if (ipAddress == null) { ipAddress = request._originatingAddress(); if (ipAddress == null) { ipAddress = request.headerForKey("remote_host"); } else { ipAddress = ((InetAddress) ipAddress).getHostAddress(); } } } if (ipAddress != null) { return ipAddress.toString(); } return null; }
If you want to rewrite your application URLs from /cgi-bin/WebObjects/YourApp.woa to /yourapp, you can set the following properties and add the apache rewrite rule
Examle to add your own error pages
# error folder <Location "/errors"> Options -Indexes Order Deny,Allow Allow from all </Location> # Proxy everything except for /error ProxyPass /errors ! # Service unavailable ErrorDocument 503 /errors/error503.html