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: How to only permit access for a particular IP for a Proxy |
|
Author |
|
Agent96
Joined: 26 May 2016 Posts: 2 Location: London
|
Posted: Thu 26 May '16 15:12 Post subject: How to only permit access for a particular IP for a Proxy |
|
|
Hi,
I am having trouble configuring my Apache WebServer version 2.4.
I want to ONLY allow a particular URL for a particular IP address. So I want to state that for IP address 1.2.3.4 they can only access: http://myserver/VS/ws/public
Note that I am running an Apache Tomcat on my server so I am using Apache WebServer (port 80) to proxy to localhost 8090. However when I attempt this, everything is blocked.
Please can someone explain what I am doing wrong? This is my entire configuration file:
Code: |
<VirtualHost *:80>
ServerName foo.org
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Location />
Order deny,allow
Deny from all
</Location>
<Directory />
Order deny,allow
Deny from all
</Directory>
<Location /VS/ws/public>
Order deny,allow
Deny from all
Allow from 1.2.3.4
ProxyPass http://localhost:8090/VS/ws/public
ProxyPassReverse http://localhost:8090/VS/ws/public
</Location>
</VirtualHost>
|
Thanks |
|
Back to top |
|
Agent96
Joined: 26 May 2016 Posts: 2 Location: London
|
Posted: Thu 26 May '16 16:16 Post subject: |
|
|
Hi.
I think I've sorted it out. I had a Varnish server forwarding to my Apache WebServer (I left this out of the original question to try to make it simpler! oops!) Since it was a request from Varnish, the IP address was being set to 127.0.0.1 and this is what Apache was evaluating.
I had to modify Varnish to add the X-Forwarded-For header and then change my config so that it was reacting to the X-Forwarded-For. Here is my updated config file:
Code: |
<Location /VS/ws/public>
SetEnvIf X-Forwarded-For ^1\.2\.3\.4 proxy_env
Order deny,allow
Deny from all
Allow from env=proxy_env
ProxyPass http://localhost:8090/VS/ws/public
ProxyPassReverse http://localhost:8090/VS/ws/public
</Location>
|
|
|
Back to top |
|
|
|
|
|
|