Apache mod_proxy_load balancer giving internal 500 error - mod-proxy

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.

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>

Express NodeJS server through Apache Proxy, error 404 for route with express parameters

I have a problem to setup Apache as a reverse proxy for my Express/Node application. The application can be reach in the correct URL but a route with Express parameters got 404 not found.
Here is my server.js configuration for the route:
app.get('/quiver/note/:path', (req, res, next) => {
const note = getQuiverNote(req.params.path)
res.json(note)
})
And here my Apache conf for reverse proxy:
<VirtualHost *:80>
ServerName quiver-node-reader.local
ProxyRequests Off
ProxyPreserveHost On
ProxyVia Full
ErrorLog "/var/log/httpd/quiver-node-reader.local-error_log"
CustomLog "/var/log/httpd/quiver-node-reader.local-access_log" common
<Proxy *>
#Require all granted
Order deny,allow
Allow from all
</Proxy>
<Location />
ProxyPass http://127.0.0.1:8080/
ProxyPassReverse http://127.0.0.1:8080/
</Location>
</VirtualHost>
When I browse my app with http://127.0.0.1:8080 everything works fine.
When I browse my app via Apache with http://quiver-node-reader.local I reach my app without any problem, but when the route with parameter is call I got 404 this time :(
Example:
http://quiver-node-reader.local/quiver/note/data%2Fformat-z%20(dev).qvnotebook%2FC9EBA21F-D425-4C99-BCAB-8B7B20235FF0.qvnote -> this route cannot be reached 404 error
http://127.0.0.1:8080/quiver/note/data%2Fformat-z%20(dev).qvnotebook%2FC9EBA21F-D425-4C99-BCAB-8B7B20235FF0.qvnote -> can be reached
Here is the log from Apache :
127.0.0.1 - - [27/Aug/2018:09:48:25 +0200] "GET /quiver/note/data%2Fformat-z%20(dev).qvnotebook%2FC9EBA21F-D425-4C99-BCAB-8B7B20235FF0.qvnote HTTP/1.1" 404 75
Finally figure out what was my problem.
My URL parmaeter is URLENCODED and there is / inside
Apache will give 404 not found if option AllowEncodedSlashes is off.
More info here https://httpd.apache.org/docs/2.2/en/mod/core.html#allowencodedslashes
Here is my config to get it working
<VirtualHost *:80>
ServerName quiver-node-reader.local
ProxyRequests Off
ProxyPreserveHost On
ProxyVia Full
ErrorLog "/var/log/httpd/quiver-node-reader.local-error_log"
CustomLog "/var/log/httpd/quiver-node-reader.local-access_log" common
AllowEncodedSlashes On
<Proxy *>
#Require all granted
Order deny,allow
Allow from all
</Proxy>
<Location />
ProxyPass http://127.0.0.1:8080/ nocanon
ProxyPassReverse http://127.0.0.1:8080/
</Location>

Session persistent in apache LB configuration

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

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>

Resources