Keep Server Online
If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.
or
A donation makes a contribution towards the costs, the time and effort that's going in this site and building.
Thank You! Steffen
Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
| |
|
Topic: Conditional reverse proxy, based on IP whitelist |
|
Author |
|
kosie99
Joined: 23 Sep 2019 Posts: 1 Location: Swords
|
Posted: Mon 23 Sep '19 15:18 Post subject: Conditional reverse proxy, based on IP whitelist |
|
|
I would like to achieve this with Apache:
If a client with an IP defined in whitelist.txt tries to access http://site1.com, I want to reverse proxy that to http://site2.com.
If the client IP is not in that list, I just want normal flow to occur and the index.html in htdocs to be served.
I was thinking of doing something along these lines, but I am not sure if that makes sense:
Code: |
RewriteMap iplist "txt:/usr/local/apache2/conf/wl.txt"
RewriteCond "${iplist:%REMOTE_ADDR}" [ I AM NOT SURE ON THE SYNTAX HERE ]
RewriteRule "^/(.*)" "http://site2.com/$1" [P]
ProxyPassReverse / http://site2.com/ |
If the above, or a version of it works, will the normal index.html be served if an IP is not in the list? Is there a better way to achieve this?
Thanks! |
|
Back to top |
|
James Blond Moderator
Joined: 19 Jan 2006 Posts: 7371 Location: Germany, Next to Hamburg
|
|
Back to top |
|
|
|
|
|
|