B4J Tutorial [ABMaterial] Several ABMaterial servers on one IP

MichalK73

Active Member
Licensed User
Hello.

I was struggling to see several ABMaterial servers visible from one IP on one port. I use it because I have one VPS test server for clients and I put there test versions for them. Each time I gave them a different port for their different ABMAterial server. As you know, each ABMaterial server must have a different port or conflict will occur.

Scheme:
1. Apache works on port 80, e.g. WEB page
2. App1 ABMaterial works on port 8080 (AppName - test1)
3. App2 ABMaterial works on port 8888 (AppName - test2)

With this arrangement we have:
http://server.com - WEB page
http://server.com:8080/test1 - App1
http://server.com:8888/test2 - App2

Unfortunately, some client companies' proxies did not allow ports other than 80,443. The solution is to use an Apache proxy.

Required modules for Apache:
mod_proxy_connect, mod_proxy_express, mod_proxy_fcgi, mod_proxy_fdpss, mod_proxy_ftp, mod_proxy_http, mod_proxy_scgi, mod_proxy_wstunnel, mod_proxy_ajp

Tested on CentOS 7. All these modules are in standard but in version 6 there is no 'wstunnel' and you need to search the web or compile manually.

We set up virtual servers in httpd.conf.

httpd.conf:
<VirtualHost *:80>
    ServerName app1.server.com
    ProxyPreserveHost On
    ProxyRequests Off
    RewriteEngine On
    ProxyPass /test1 http://localhost:8888/test1
    ProxyPass /css http://localhost:8888/css
    ProxyPass /js http://localhost:8888/js
    ProxyPass /font http://localhost:8888/font
    ProxyPass /ws ws://localhost:8888/ws
    ServerAlias app1
</VirtualHost>


<VirtualHost *:80>
    ServerName app2.server.com
    ProxyPreserveHost On
    ProxyRequests Off
    ProxyPass /test2 http://localhost:8080/test2
    ProxyPass /css http://localhost:8080/css
    ProxyPass /js http://localhost:8080/js
    ProxyPass /font http://localhost:8080/font
    ProxyPass /ws ws://localhost:8080/ws
    ServerAlias app2
</VirtualHost>
After restarting the Apache server we have the result in the form:
1. http://server.com - WEB website
2. http://app1.server.com/test1 - webapp ABMaterial (AppName test1)
3. http://app2.server.com/test2 - webapp ABMaterial (AppName test2)

In this way, we get rid of the port address because it is automatically handled by the Apache proxy. Works equally well at cloudflare.com where we can force SSL from CF and on our side remains without SSL. You might as well enable SSL on your servers.

Tips: using 'mod_proxy_balancer' we can make our own balancer server by distributing the load over several machines with identical ABMaterial servers.

Regards
 
Last edited:

alwaysbusy

Expert
Licensed User
Thank you for the nice tutorial @MichalK73!

We do outsource this kind of stuff, but it is always great to read on how it is done (and even try it out on my personal servers at home :) )
 

OliverA

Expert
Licensed User
I can see from the configuration how Apache knows where to sent access for /test1 and /test2 properly (since the path portion is unique and therefore Apache can distinguish between them). But, how does Apache know how to properly handle /css, /js, /font, and /ws? These are not unique path names for the given proxy mappings (meaning /css is mapped both to port 8080 and 8888).
 

MichalK73

Active Member
Licensed User
I can see from the configuration how Apache knows where to sent access for /test1 and /test2 properly (since the path portion is unique and therefore Apache can distinguish between them). But, how does Apache know how to properly handle /css, /js, /font, and /ws? These are not unique path names for the given proxy mappings (meaning /css is mapped both to port 8080 and 8888).
Well, I forgot to add ServerName to VirtualHost :)
Now it's ok
 
Top