There are many proxy software, squid is the popular one, but I don’t want to install it as I can reuse the Apache’s proxy function. Below I will introduce how to setup the forward proxy with authentication function in Apache 2.2.x.(The example based on Apache 2.2.x shipped with Oracle Linux 6)
- Edit /etc/httpd/conf/httpd.conf, make sure mod_proxy module has been set to be loaded
| LoadModule proxy_module modules/mod_proxy.so |
- Make sure the /etc/httpd/modules/mod_proxy.so exists
- Find the mod_proxy keyword, and add following
| <IfModule mod_proxy.c> |
| ProxyRequests On |
| ProxyRemote * http://<upper proxy IP>:<port> |
| |
| <Proxy *> |
| Order deny,allow |
| Deny from all |
| Allow from all |
| AuthType Digest |
| AuthName <Realm Name> <--- Realm Name |
| AuthDigestDomain / <--- Digest prtected domain |
| AuthUserFile <digest password file> <--- Password file generated by htdigest command |
| require user <username> |
| </Proxy> |
- Generate a digest password file contains the user/password info
| |
| >> <--- input password the first time |
| >> <--- input password the second time |