Session persistent in apache LB configuration - linux

I am configuring apache LB , where i faced a problem regarding the session persistence issue which i am not able to solve after trying multiple option.
Note this is not for web application, this is regarding my application server.
Below is the configuration i tried:
<VirtualHost *:7802>
ProxyPreserveHost On
ProxyPass /MenuMangement balancer://apacheLB
ProxyPassReverse /MenuMangement balancer://apacheLB
Header add Set-Cookie "ROUTEID=.%{BALANCER_WORKER_ROUTE}e; path=/"
env=BALANCER_ROUTE_CHANGED
<Proxy balancer://apacheLB>
BalancerMember https://xx.xx.xx.xx:7802/MenuMangement route=j1
loadfactor=50
BalancerMember https://xx.xx.xx.xx:7802/MenuMangement route=j2
loadfactor=50
ProxySet lbmethod=bytraffic stickysession=ROUTEID
ProxySet lbmethod=bytraffic stickysession=ROUTEID
</Proxy>
</VirtualHost>
Another option
ProxyPass "/test" "balancer://mycluster"
stickysession=JSESSIONID|jsessionid scolonpathdelim=On
<Proxy "balancer://mycluster">
BalancerMember "http://xx.xx.xx.xx:8595" route=node1
BalancerMember "http://xx.xx.xx.xx:8595" route=node2
</Proxy>
Note: Try opening jvm port on application tomcat and then route request on that port
Please suggest the way forward on this..
Linux #Apache #loadbalancing

Related

Apache reverse proxy for Node sever

I have a apache-based server running on https://example.com and inside of it a node application running on port 3000. Requests can be succesufully sent to https://example.com:3000, however, since I am planning to run multiple applications, I would like to set-up some reverse proxy for different applications. In order to do it I added the following lines to the apache conf file:
<VirtualHost *:80>
ServerAdmin foo#example.com
ServerName example.com
ProxyRequests off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
<Location /myapp1>
ProxyPass http://localhost:3000
ProxyPassReverse http://localhost:3000
</Location>
<Location /myapp2>
ProxyPass http://localhost:3010
ProxyPassReverse http://localhost:3010
</Location>
</VirtualHost>
This approach does not seem to be working as requests to https://example.com/myapp1 are not returning anything.
Update
After some debugging, I found out that the .conf file was actually being included inside a <VirtualHost> tag which was triggering the error (nested <VirtualHost> tags). Now I simply have the following:
ProxyRequests Off
ProxyPreserveHost On
ProxyVia Full
<Proxy *>
Require all granted
</Proxy>
<Location /myapp1>
ProxyPass http://127.0.0.1:3000
ProxyPassReverse http://127.0.0.1:3000
</Location>
<Location /myapp2>
ProxyPass http://127.0.0.1:3010
ProxyPassReverse http://127.0.0.1:3010
</Location>
Now when I hit https://example.com/myapp1 I get Not Found - 500 Internal Server Error. Which at least show that routing is being recognized. Any ideas how to proceed with the debugging process?
Any ideas how to properly set up it
I finally managed to fix my problem last week. The following line of code was missing from my reverse proxy configuration:
SSLProxyEngine on
Thanks for all the help.

Not able to access other folder rather than node.js app

I have deployed an angular universal app on port 4000 and I have used a reverse proxy to make it live on port 80.
Application Path:/var/html/www/eduglobe/eduglobe/ (this path i access as domainname.com)
But I am not able to access Below path:/var/html/www/test/index.html ( This I am not able to access at domainname.com/test/index.html)
php and node.js server working fine.
Code for site-enabled 000-default.conf
ProxyRequests Off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ServerName demo.eduglobe.in
DocumentRoot /var/www/html/eduglobe/eduglobe
<Location />
ProxyPreserveHost On
ProxyPass http://127.0.0.1:4000/
ProxyPassReverse http://127.0.0.1:4000/
</Location>
Have you enabled proxy_http?
The followings works for me!
Check that the Location directive points to the folder that hosts the app which is not the DocumentRoot (/) of the site enabled.
DocumentRoot /var/www/html/
<Location /demo>
ProxyPreserveHost On
ProxyPass "http://127.0.0.1:8080/"
ProxyPassReverse "http://127.0.0.1:8080/"
</Location>

Apache 2.4 Reverse proxy to Node Application on Docker

I have a dedicated server on Apache 2.4 and I made a node application which is running on a Docker container and listenning on the port 5847
So I am trying to configure my apache to make a reverse Proxy to http://my.url.com:5847 on a Debian 8 machine
When I made this, I have the start page of apache "It Works" but not my application. Of course, If I check http://my.url.com:5847 in my navigator, it works fine, but why my reverse Proxy doesn't work?
This is my my.url.com.conf apache config file :
<VirtualHost *:80>
ServerAdmin hello#my-url.com
ServerName my.url.com
ProxyPass "/" "http://my.url.com:5847/"
ProxyPassReverse "/" "http://my.url.com:5847/"
</VirtualHost>
So I'm quite desesperate, I also tried to add
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
I also tried with Required all granted, I tried with the <Location /> directive, with ProxyRequests Off and On too but nothing is working and I don't understand what is going wrong...
Can you help me please? What am I doing wrong?
This wks for me (apache 2.4, node.js runs in 192.168.32.35 on port 3003), on Debian 8
<VirtualHost feed.mydomain.net:3003>
ServerName feed.mydomain.net
ServerAdmin yves#mydomain.com
DocumentRoot /var/www/html
<Location />
ProxyPass http://192.168.32.35:3003/
ProxyPassReverse http://feed.mydomain.net:3003/
Order allow,deny
Allow from all
</Location>
LogLevel trace1 ssl:warn rewrite:trace1
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Okay, so ... I think I found my error, I was writing an conf archive without .conf extension in sites-enabled and that's why apache wasn't taking my configuration... I re-made my configuration file in sties-enabled and then enabled it from apache with a2ensite my.url.com.conf and now it works...
Sorry for the bas question, nothing to do with reverse proxy!

Apache Virtual Proxypass nodejs application - Empty page

I'm running an apache server with a proxypass for my node js application.
Here's what I got in my virtualhost :
ProxyRequests Off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass / http://127.0.0.1:3333/
ProxyPassReverse / htttp://127.0.0.1:3333/
<Location />
Order allow,deny
Allow from all
</Location>
Basically I want to redirect every request to my nodejs application and it works when I use the direct link.
My issue is when I try to reach it using tier app ( e.g Postman ) it doesn't return my html page. I need tier apps & site to get the meta tags to share on social networks (FB, TW, ...).
My vhost knowledge is really weak, I'd be really grateful if someone could help me on this case.
Thanks !
This should work just fine
<VirtualHost *:80>
ProxyPreserveHost On
ProxyPass / http://127.0.0.1:3333/
ProxyPassReverse / htttp://127.0.0.1:3333/
</VirtualHost>

Apache mod_proxy_load balancer giving internal 500 error

I was trying to load balance the requests coming uri /v1.0/api to my backend instances using Apache mod_proxy_load balancer:
I tried with following configuration:
<Proxy *>
Require all granted
</Proxy>
ProxyPass /v1.0/api/ !
ProxyPass / balancer://mycluster/ stickysession=BALANCEID nofailover=On
ProxyPassReverse / https://10.23.45.66:8081/v1.0/api/
ProxyPassReverse / https://10.23.45.67:8081/v1.0/api/
<Proxy balancer://mycluster>
BalancerMember https://10.23.45.66:8081/v1.0/api/ route=http1
BalancerMember https://10.23.45.67:8081/v1.0/api/ route=http2
</Proxy>
<Location /v1.0/api/>
SetHandler /v1.0/api/
Require all granted
</Location>
Kindly help me in fixing this problem.
Thanks,
Pradeep
I got it fixed myself.
by enabling few more modules: mod_proxy, mod_proxy_http.
Thanks.

Resources