40

I need to set up a proxy with authentication to verify the behavior of an application that connects to the internet.

I am trying to set-up an Apache installation with forward proxy and authentication, and even though I am close to make it work, I wonder if there is maybe a better way, as the configuration is fairly esoteric.

How can Apache be configured to work this way?

Is there any other good option that is already configured? Maybe some VM or some other software tool, instead of Apache?

Mario Ortegón
  • 18,670
  • 17
  • 71
  • 81

2 Answers2

70

For the record, this is how I set up apache to be used as a forward-proxy with basic authentication:

Open http.conf

Uncomment the following LoadModule directives to enable proxy funcionality

LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so

Add the following directives to the http.conf to enable authentication

ProxyRequests On
ProxyVia On

<Proxy *>
    Order deny,allow
    Allow from all
    AuthType Basic
    AuthName "Password Required"
    AuthUserFile password.file
    AuthGroupFile group.file
    Require group usergroup
</Proxy>

Create a password.file using the htpasswd.exe utility. Place it on the Apache Root directory

htpasswd.exe -c password.file username

Create a group.file using a text editor at the same level as the password.file with the following contents

usergroup: username

Then run apachectl restart to pick up the configuration changes.

tgdavies
  • 10,307
  • 4
  • 35
  • 40
Mario Ortegón
  • 18,670
  • 17
  • 71
  • 81
  • Where is the "Apache Root Directory"? I'm proxying to another site located elsewhere... so there is no home directory.. do you mean the folder of the Apache executable?? – Spock Aug 18 '14 at 20:26
  • 2
    If you want multiple users in the same group, how do you manipulate the group.file to do this? Comma separated list? Space separated? Something else? – istrasci May 26 '15 at 00:06
  • Note that if you're using Ubuntu, you can install the `htpasswd` binary through the following command: `sudo apt-get install apache2-utils` – FriendFX Mar 08 '16 at 10:38
  • 1
    The Allow, Deny, and Order directives, provided by mod_access_compat, are deprecated and will go away in a future version. You should avoid using them. – Antti A Jun 08 '18 at 08:56
0

I use Squid.

It's quite easy to install it and to setup it with a basic authentication with the "auth_param" directive in the configuration file.

You will find some samples, understand how it works, and all details about the auth_param on Squid Website

chburd
  • 4,131
  • 28
  • 33