Apache Proxy balancer overuling file access limits - apache

I have 1 load balancer server and 2 app servers which do load distribution. Now i have a strange problem that the
<Files ~ "^\.ht">
Order allow,deny
Deny from all
</Files>
rule dous not get triggerd when the request gets forwarded to the app servers.
Setup is:
<Proxy balancer://catdefault>
BalancerMember http://xx.xxx.xxx:8081
BalancerMember http://xx.xxx.yyy:8081
</Proxy>
And in the virtual host i get it included like this:
ProxyPass / balancer://catdefault/
ProxyPassReverse / balancer://catdefault/
The strange thing is that when i apply the Files rule in the app server which is a balance memger ex. http://xx.xxx.xxx:8081 then the rule gets respected.
Now we agreed not to makie rew rulles on the app server because they will be later or many of them and administration will be heavy.
Any idea how i can make the files work from the load balancer server and not the http://xx.xxx.xxx:8081 servers???

<Directory> or <Files> directives will only apply to objects that reside in the filesystem.
Perhaps something like this can help (untested):
ProxyPassMatch "(?i)\.ht([^/]*)$" !
ProxyPass / balancer://catdefault/
ProxyPassReverse / balancer://catdefault/

Related

path based routing on apache

I have regular load balancing working in Apache. I want to change that to use path based routing and load balancing
I am looking for some guidance on path based routing in Apache
Currently I have 3 servers running Apache.
I have load balancer, which has configuration as follows
What I want to change this is path based routing /load balancing
For ex: if someone types url/app , it should automatically be redirected app server on port 3000
if someone types url/rpt , it should automatically be redirected 3230
if someone types url/azn , it shoudl be redirected to 4010
<Proxy balancer://app0108>
#BalancerMember https://app01.us.ray.com route=1
BalancerMember https://p.q.r.s route=1
#BalancerMember https://app02.us.ray.com route=2
BalancerMember https://a.b.c.d route=2
#BalancerMember https://app03.us.ray.com route=3
BalancerMember https://x.y.a.sd route=3
ProxySet stickysession=ROUTEID
ProxyPass / "balancer://app0108/" failonstatus=503 maxattempts=10 timeout=2400
ProxyPassReverse / "balancer://app0108"
ProxyStatus On
ServerName xxxxx:443
ServerAlias xxxxxx
ErrorLog logs/alb.errors.log
thanks

Apache config api endpoint

I am running a vue js application as a v-host (app.test.com) on
http://app.test.com
The backend is a go application (which implements a webserver on its own) and is running on
http://localhost:8000
Is it possible to configure apache to redirect/proxy all request that go to http://app.test.com/api to http://localhost:8000 ?
Let's say i call http://app.test.com/api/endpoint1 from the vue application i'd like it to be proxied to http://localhost:8000/api/endpoint1.
I normaly have a dedicated dns for the api and using this config then in the v-host:
ProxyRequests Off
ProxyPreserveHost On
ProxyPass / http://0.0.0.0:8000/
ProxyPassReverse / http://0.0.0.0:8000/
which works good.
But i can't figure out how to use this in a allready defined v-host.
Any hints/examples?
Many thanks
Sorry for this question. Managed to run this .. forgot to add the Proxy * directive to the config...
ProxyRequests Off
ProxyPreserveHost On
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass /api/ http://0.0.0.0:8000/api/
ProxyPassReverse /api/ http://0.0.0.0:8000/api/
does it all, if someone Needs this

Running multiple root\no context web apps on single host

I have a host with a single web app and at the moment I am accessing it via www.hostnameA.com/ as the web app is deployed to tomcat/webapps as the tomcat ROOT web app.
Now I need to add another web app to my host and I also want this one to have no context either but will access it via another hostname www.hostnameB.com/ but I can only deploy one ROOT tomcat web app.
I should have added that I am using apache as well and my virtual host looks like:
<VirtualHost *:80>
ServerName www.hostnameA.com
ProxyRequests Off
ProxyPreserveHost On
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass / http://localhost:8080/
ProxyPassReverse / http://localhost:8080/
</VirtualHost>
I tried renaming the war file to webAppA and then appending that to the proxypass but it gave me a 400 error and kept appending /webAppA to the URL:
ProxyPass / http://localhost:8080/webAppA
Is there a solution to this? I dont really want to run multiple instances of tomcat on different ports just for this, is there another option?
As discussed above, most straightforward solution would be to use Apache's mod_proxy_ajp, allowing proxying and AJP forwarding at the same time. Configuration should look something like:
<VirtualHost *:80>
ServerName www.hostnameA.com
ProxyPass / ajp://localhost:8009/webAppA/
ProxyPassReverse / http://www.hostnameA.com/webAppA
[...]
...and same with B for www.hostnameB.com.

apache http server load balancer monitoring

I configured apache http server to act as load balancer using mod-proxy module
<Proxy balancer://clusterABCD>
BalancerMember http://192.168.0.222:8080/geoserver/wms loadfactor=8
BalancerMember http://192.168.0.14:8081/geoserver/wms loadfactor=8
BalancerMember http://192.168.0.222:8082/geoserver/wms status=+H
ProxySet lbmethod=bytraffic
Order allow,deny
Allow from all
</Proxy>
ProxyPass /LGroup balancer://clusterABCD/
Is there any way to monitor the load balancer functionality
My question is
is there any way to find from which BalanceMember the request is processing
is there any settings available to increase functionality
Thanks IN Advance
In response to your both your questions, yes it is possible but you will need to enhance your configuration for Apache Load Balancing via Mod Proxy to have this functionality available.
I suggest you use the sample setup below:
<VirtualHost *:80>
ProxyRequests off
ServerName servername.local
<Proxy balancer://mycluster>
# TomcatA
BalancerMember http://172.20.20.101:8080 route=tomcatA
# TomcatB
BalancerMember http://172.20.20.102:8080 route=tomcatB
# TomcatC
BalancerMember http://172.20.20.103:8080 route=tomcatC
# Security – to determine who is allowed to access
# Currently all are allowed to access
Order Deny,Allow
Deny from none
Allow from all
# Load Balancer Settings
# We will be configuring a simple Round
# Robin style load balancer. This means
# that all nodes take an equal share of
# of the load.
ProxySet lbmethod=byrequests
</Proxy>
# balancer-manager
# This tool is built into the mod_proxy_balancer
# module and will allow you to do some simple
# modifications to the balanced group via a gui
# web interface.
<Location /balancer-manager>
SetHandler balancer-manager
# I recommend locking this one down to your
# administering location
Order deny,allow
Allow from all
</Location>
# Point of Balance
# This setting will allow to explicitly name the
# location in the site that we want to be
# balanced, in this example we will balance "/"
# or everything in the site.
ProxyPass /balancer-manager !
ProxyPass / balancer://mycluster/ stickysession=JSESSIONID|jsessionid nofailover=Off scolonpathdelim=On
To view the Balance Request you need to have the module
mod_proxy_balancer
installed and then use the configuration from above.
In regards to availability, it depends on the Load Balancer Settings the Round Robin approach share the traffic equally between the nodes, and is seen as possibly the best option for availabilty:
ProxySet lbmethod=byrequests
Also, if you are considering sharing sessions with your request from Apache to app servers, then configuration to the AJP instead of the HTTP port is needed along with changes needed on the Application Servers (such as Tomcat). More details are available at:
Load Balancing: Apache versus Physical Appliance
May be too simple, but what about monitoring the (access-) logs of your balancer members? This should show you, which member is processing the request.

How to configure Apache to proxy exactly one file?

(I must be dense - I just can't figure out the Apache documentation on how to do this.)
To speed up some swf development I'm doing, I want to have my local machine fetch my local swf when I browse to our studio's test website. Just the one local swf only - with the rest pulled from the test website.
So I set up apache on port 80 with mod_proxy and proxy_http_module, then added an entry for HOSTS to say the test server is 127.0.0.1. What I need are the magical incantations to put in httpd.conf to say "every call requesting http://test/blah goes to 10.1.1.whatever EXCEPT http://test/blah/foo.swf which goes to c:\proj\foo.swf".
Can someone help with this? Thank you.
There is a simple syntax for disallowing a particular URL from proxying:
ProxyPass /blah/foo.swf !
ProxyPass /blah http://10.1.1.whatever
For the record here's what I ended up with, roughly:
<VirtualHost *>
ServerName (testserver-dns)
ProxyRequests Off
ProxyPreserveHost On
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass /path/to/swf !
ProxyPass / http://10.1.2.3/
ProxyPassReverse / http://10.1.2.3/
<Location />
Order allow,deny
Allow from all
</Location>
</VirtualHost>