WildFly 9 load balancing with mod_cluster - apache

I'm trying to configure load balancing with jboss wildfly running on windows for the first time. I d'ont have an experience with jboss or apache httpd. i have installed apache httpd and mod_cluster, than i added the required modules from mod_cluster to appache httpd then in httpd.conf i added this configuration :
<IfModule ssl_module>
SSLRandomSeed startup builtin
SSLRandomSeed connect builtin
</IfModule>
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
LoadModule slotmem_module modules/mod_slotmem.so
LoadModule manager_module modules/mod_manager.so
LoadModule proxy_cluster_module modules/mod_proxy_cluster.so
LoadModule advertise_module modules/mod_advertise.so
Listen 127.0.0.1:8080
<VirtualHost 127.0.0.1:8080>
<Location /mod_cluster_manager>
SetHandler mod_cluster-manager
Order deny,allow
Deny from all
Allow from 127.0.0.
</Location>
KeepAliveTimeout 60
MaxKeepAliveRequests 0
ManagerBalancerName mycluster
ServerAdvertise On
</VirtualHost>
When i put a clustered ejb application in the deployments and start the server with default standlone-ha.xml values i can access to /mod_cluster_manager but there is no node detected
I don't know if theres is further configuration i found a tutorial but it's not well explained anything can help thank you

You are missing some configuration, so there is no communication between Apache and Wildfly currently.
First, change the Port of your virtual host above to 6666 (common default for mod_cluster-manager virtual host) or anything other than 8080. You seem to be running Wildfly and Apache on the same host, 8080 is Wildfly's default HTTP listener Port, so instead of changing Wildfly's default, use something else for Apache.
Then you have two options:
a) enable MCPM in Apache's part of mod_cluster to get multicast auto-configuration
<VirtualHost 127.0.0.1:6666>
...
EnableMCPMReceive
</VirtualHost>
b) don't use multicast, and explicitly set the proxies in Wildfly's standalone.xml
<subsystem xmlns="urn:jboss:domain:modcluster:2.0">
<mod-cluster-config proxies="127.0.0.1:6666" ...>
...
</mod-cluster-config>
</subsystem>

Related

Rundeck running behind apache proxy does not show "Resource Node Models"

I have a rundeck server which is running on server A with 10.10.100.120 VIP. I configured also a proxy on Server B having ip address 192.168.38.205.
So, Proxy server redirects incoming traffic to VIP:4440 in order to access Rundeck application.
To get there I have 2 options; Using application's VIP or Server B's ip address (proxy server).
Application server is a Centos 7, running Rundeck 3.0.22
Proxy server is a Centos 6 running apache 2.2
Here is my httpd configuration on proxy server:
<VirtualHost *:80>
ProxyPreserveHost On
# Servers to proxy the connection, or;
# List of application servers:
# Usage:
# ProxyPass / http://[IP Addr.]:[port]/
# ProxyPassReverse / http://[IP Addr.]:[port]/
# Example:
ProxyPass / http://10.10.100.120:4440/
ProxyPassReverse / http://10.10.100.120:4440/
ServerName localhost
</VirtualHost>
Proxy modules loaded:
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
LoadModule proxy_ftp_module modules/mod_proxy_ftp.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
LoadModule proxy_connect_module modules/mod_proxy_connect.so
I followed instructions here:
From Digital ocean's proxy guide!
The problem is :
When I access the application from proxy and click on "Resource Model" tab in order to add node file under project > project settings > edit nodes, new window does not appear.
Normally, It should appear, by this way I could select the model that I want to use as node file.
Expected result:
From_rundeck_Server1
From_rundeck_server2
Proxy server problem:
From_proxy_server1
From_proxy_Server2
That's a Known Issue, to solve it change the grails.serverURL (rundeck-config.properties file usually at /etc/rundeck/rundeck-config.properties) value from "localhost" to your server hostname. Check this: https://groups.google.com/d/msg/rundeck-discuss/I94cVxK_6kQ/0a3PPyygAwAJ

Reverse Proxy on Apache

I am naive to apache and network management. I have GeoServer hosted on one of my virtual machine which works correctly by the URL as localhost/geoserver . Also, I have successfully mapped one link say abc.ac.in/pqr/ (Link changed) to the localhost of virtual machine displaying the index.html of apache. But when I try to access abc.ac.in/pqr/geoserver then I get an error as /geoserver was not found on this server. Also, the link gets changed to abc.ac.in/geoserver.
I have used the reverse proxy as below in the httpd conf of apache as below:-
<IfModule proxy_module>
ProxyPass "/geoserver" "http://localhost:8080/geoserver"
ProxyPassReverse "/geoserver" "http://localhost:8080/geoserver"
</IfModule>
and uncommented below lines:-
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
LoadModule proxy_http_module modules/mod_proxy_http.so
Please let me know whether is this the issue from configuration side or related to mapping from network side and the possible workaround if any.

Sticky session not working with multiple apache vhosts and multiple JBoss 7.2 server-groups

Having a specific cluster architecture with the following details:
Load balancer (10.10.0.1) using Apache's mod_cluster 1.2.0 without advertising using multicast
2 JBoss AS 7.2 servers (jboss-instance-1, jboss-instance-1) in domain mode (host and slave), i'm using proxy-list instead of multicast
In domain.xml i have the following settings (only important snippets):
...
<subsystem xmlns="urn:jboss:domain:modcluster:1.1">
<mod-cluster-config advertise-socket="modcluster" connector="ajp" balancer="${mycluster.modcluster.balancer:DefaultBalancer}" proxy-list="10.10.0.1:6677">
<dynamic-load-provider>
<load-metric type="busyness"/>
</dynamic-load-provider>
</mod-cluster-config>
</subsystem>
...
...
<server-group name="SG1" profile="ha">
<system-properties>
<property name="mycluster.modcluster.balancer" value="SG1Balancer"/>
</system-properties>
<jvm name="default"/>
<socket-binding-group ref="ha-sockets"/>
</server-group>
<server-group name="SG2" profile="ha">
<system-properties>
<property name="mycluster.modcluster.balancer" value="SG2Balancer"/>
</system-properties>
<jvm name="default"/>
<socket-binding-group ref="ha-sockets"/>
</server-group>
....
And in host.xml (same as in slave and host):
....
<servers>
<server name="server-1" group="SG1" auto-start="true">
<socket-bindings port-offset="1"/>
</server>
<server name="server-2" group="SG2" auto-start="true">
<socket-bindings port-offset="2"/>
</server>
....
I need to point each virtual hosts to a specific server-group, so this is my solution for it:
www.vhost1.com -> SG1Balancer, which is attached to group=SG1, so it will load balance between:
jboss-instance-1's server-1
jboss-instance-2's server-1
www.vhost2.com -> SG2Balancer, which is attached to group=SG2, so it will load balance between:
jboss-instance-1's server-2
jboss-instance-2's server-2
Here's my httpd configuration sets:
loadbalancer.conf:
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
LoadModule slotmem_module modules/mod_slotmem.so
LoadModule manager_module modules/mod_manager.so
LoadModule proxy_cluster_module modules/mod_proxy_cluster.so
LoadModule advertise_module modules/mod_advertise.so
<IfModule manager_module>
Listen 0.0.0.0:6677
ManagerBalancerName ddrct-cluster
<VirtualHost *:6677>
ServerName RecetteDtvLb1
<Location />
Order deny,allow
Allow from 0.0.0.0
</Location>
# No server advertising
# we're using proxy-list
ServerAdvertise Off
KeepAliveTimeout 300
MaxKeepAliveRequests 0
EnableMCPMReceive
<Location /mcm>
SetHandler mod_cluster-manager
Order deny,allow
Allow from 0.0.0.0
</Location>
</VirtualHost>
</IfModule>
vhosts.conf:
ProxyRequests Off
NameVirtualHost *:80
<VirtualHost *:80>
ServerName www.vhost1.com
ProxyPass / balancer://SG1Balancer stickysession=JSESSIONID
ProxyPassReverse / balancer://SG1Balancer
ProxyPreserveHost On
ErrorLog "logs/vhost1_error.log"
CustomLog "logs/vhost1_access.log" common
</VirtualHost>
<VirtualHost *:80>
ServerName www.vhost2.com
ProxyPass / balancer://SG2Balancer stickysession=JSESSIONID
ProxyPassReverse / balancer://SG2Balancer
ProxyPreserveHost On
ErrorLog "logs/vhost2_error.log"
CustomLog "logs/vhost2_access.log" common
</VirtualHost>
Everything is running fine, deployed apps in G1 can be used through www.vhost1.com and vice versa for G2, the problem is all about session stickyness, here are the symptoms:
My browser is accepting JSESSIONID cookie, but having a content like this: KhH7gInyAFPsILN6mYDQ84Kf.jboss-instance-1:server-1 will not get my next request sticked to jboss-instance-1's server-1, the load balancer will switch my requests between jboss-instance-1's server-1 and jboss-instance-2's server-1 and each time it changes the JSESSIONID cookie content.
When i manually edit the content of JSESSIONID cookie (using firecookie plugin) to remove the server name like this: KhH7gInyAFPsILN6mYDQ84Kf.jboss-instance-1, my requests will be sticking on jboss-instance-1, leading to a correct behaviour
Did not get too much documentation about multi-vhost and multi-server-group clustering and load balancing configurations, it was my own guess to implement such configuration, i may get it wrong ... any help ?
Issue resolved, from KB182813:
Do not put the "-" character in your balancer name as it has been known to create sticky session issues
Do not use uppercase characters in your balancer name
Regarding node names
The relevant issue MODCLUSTER-435 was resolved in Nov 2014. It is safe to use upper case characters and dashes in any decent mod_cluster version, i.e. 1.3.x.
Regarding ProxyPass
One doesn't need to set anything ProxyPass related unless one wants to do something special. The aforementioned setting is redundant and weird. Mod_cluster uses mod_proxy as its backend, so it actually dynamically configures proxy pass balancer members for you. It makes sense to have your own ProxyPass additional setting if you wish to alter the balancer's behaviour in a custom way, e.g.
One needs to have static content served from the Apache HTTP Server while the dynamic one being proxied to Wildfly workers:
ProxyPassMatch ^/app/static/ !
ProxyPass /app balancer://qacluster stickysession=JSESSIONID|jsessionid nofailover=on
ProxyPass / !
ProxyPassReverse /app balancer://qacluster
ProxyPassReverseCookieDomain / /app/
ProxyPassReverseCookiePath / /app/
ProxyPreserveHost on

How to create a proxy with apache 2.2?

I have a web app deployed on Tomcat. So my web is reachable with the url http//localhost:8080/myapp. Tomcat is install on my computer. I've installed Apache 2.2 (xampp) because i want to make a proxy. My aim is to build a proxy in order to have the following use case :
1. http://127.0.0.1:8080/myapp => displays my web app(as now)
2. http://mysuperapp.com/myapp => displays my web app ( here the http request is handled by my http://localhost:8080/myapp and the navigator always displays url http://mysuperapp.com/myapp).
Here is the configuration i use :
httpd.conf :
...various non-proxy-related modules omitted...
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
LoadModule proxy_connect_module modules/mod_proxy_connect.so
LoadModule proxy_ftp_module modules/mod_proxy_ftp.so
LoadModule proxy_html_module modules/mod_proxy_html.so
LoadModule proxy_http_module modules/mod_proxy_http.so
<VirtualHost *:80>
ServerName mysuperapp.com
ProxyPass / http://localhost:8080/
ProxyPassReverse / http://localhost:8080/
ProxyPassReverseCookieDomain localhost mysuperapp.com
ProxyPreserveHost On
</VirtualHost>
When i try the url mysuperapp.com/myapp i cannot see my webapp. Is it something wrong ?
I'm assuming that mysuperapp.com correctly resolves to the computer that apache is running on? Just by mentioning a server name in apache's config, doesn't make it accessible under that name.
Is Apache running on the same computer as tomcat? If not, you can't use http://localhost:8080/ but will have to give the name your tomcat is accessible to Apache under (e.g. log in to the Apache-running computer and access your webapp from a browser there. If it's a headless server, use lynx or w3m - those are shell-based (text-mode) browsers.
If it's not any of these reasons, please specify "I cannot see my webapp" further: What can you see instead?
Edit: I've seen you've made some (moderator-rejected) edits to this answer: You should add these comments as "comments" below this answer.
From those edits I have the feeling that you'll have to work on the DNS side - e.g. you'll need to figure out how to make your Apache available under mysuperapp.com: So far you have configured it to reply correctly if it has been reached under that domain name, but it seems that the general name resolution does not point to it: Try ping mysuperapp.com. If that doesn't resolve to the IP-address of your Apache, you don't need to worry about anything else.

HOWTO transfer a request made to an Apache server to an IIS server without using a URL redirect?

My Apache 2.2.9 runs on Debian Lenny 5.0.1 with 2 network interfaces, one interface has a public IP and hostname, the other is not configured. This machine caters to services that run on the LAMP stack.
There is a Windows Server 2008 SP2 machine running IIS 7 that serves our ASP.net needs. The box can be configured to be either on a local or a public IP and has 2 network interfaces as well.
Both the servers serve over SSL and Apache is public facing.
Is there a way when a request such as https://foo.com/contentfromiis/ is made the browser can serve contents from the IIS server without using a redirect and transferring to https://bar.com/iwastransferedhere/. In other words the user must not /experience/ any switch happening. Thanks!
If I understand your situation correctly, I believe you may be able to use mod_proxy to do what you want. Basically, Apache would act as a "reverse proxy" for the requests that you actually want to serve from IIS. Note that a reverse proxy isn't like a normal HTTP proxy. From the mod_proxy docs:
A reverse proxy ... appears to the
client just like an ordinary web
server. No special configuration on
the client is necessary. The client
makes ordinary requests for content in
the name-space of the reverse proxy.
The reverse proxy then decides where
to send those requests, and returns
the content as if it was itself the
origin.
Yes, what Laurence Gonsalves says. Here is a simple as simple can be configuration file that I've taken from a caching reverse proxy server of mine. You should be able to work in some URL matching but I've not done that myself.
# httpd *reverse proxy caching server* config file for apache httpd 2.2
ServerRoot "C:/Program Files/Apache Group/Apache2"
#must exist, no reason to have anythign in it
DocumentRoot "C:/Program Files/Apache Group/Apache2/htdocs"
Listen 127.0.0.1:80
Listen 192.168.1.33:80
ServerAdmin stu#thompson.name
ServerName proxy.server.com
LoadModule auth_module modules/mod_auth.so
LoadModule log_config_module modules/mod_log_config.so
LoadModule mime_module modules/mod_mime.so
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
### PROXY CONFIGURATION ###
ProxyRequests Off
ProxyVia On
### VH ###
<VirtualHost 192.168.1.33>
ProxyPass / http://192.168.1.34:80/
ProxyPassReverse / http://192.168.1.34:80/
LogLevel info
</VirtualHost>
### LOGGING CONFIGURATION ###
# error log will not catch proxied content
ErrorLog logs/error.log
LogLevel info
LogFormat "%{Host}i %v %h %l %u %t \"%r\" %>s %b common
CustomLog logs/access.log common
TypesConfig conf/mime.types