# How to install or use mod_proxy with apache2?

## patniemeyer

I am pulling my hair out over what seems like it should be easy - I want to use mod_proxy with apache on my Gentoo 1.12 AMD 64 system.

I understand that mod_proxy is now part of apache2.  But I'm not sure what this means for me using it.  I have done an "emerge apache" and do not see a mod_proxy.so in /usr/lib64/modules/apache.  I tried simply using the <Proxy> directive but it does not seem to be recognized.  I know that there is no "mod_proxy" ebuild.

So I take it that I need to pass it some kind of USE options when I install apache.  I searched far and wide for info on this but cannot find it.  So I looked in the ebuild file and found the IUSE options.  In there I see "proxy", "proxy_balancer", etc.  So I tried:

  USE="proxy proxy_balancer" emerge --newuse apache

but it just tells me that everything is up to date.

I saw that there is a mod_proxy_html ebuild and thought that maybe it would include the mod_proxy stuff, so I tried to install it but it emerge tells me that it's masked.  I understand that this means that it's in "testing" on my architecture.  Is mod_proxy not installed due to the AMD 64-ness of my system?

Any pointers would be greatly appreciated.

Pat

----------

## scherz0

The apache ebuild uses the new APACHE2_MODULES variable.

Its default value (from /usr/portage/profiles/base/make.defaults) seems to be :

```
APACHE2_MODULES="actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias"
```

Edit /etc/make.conf, add the previous line and insert proxy.

----------

## gentoo_ram

Once you add 'proxy' to the APACHE2_MODULES in your /etc/make.conf, then you must do a couple other things:

1.  Add "-D PROXY" to APACHE2_OPTS in /etc/conf.d/apache2

2.  Make sure /etc/apache2/modules.d/50-mod_proxy.conf exists.  If not, create it.  I used the proxy as an ad blocker.  Make sure you set your security settings properly.

I used to use the Apache web proxy.  But now I'm using squid... it's a lot faster than apache as a proxy.

Here's what my /etc/apache2/modules.d/50-mod_proxy.conf file looks like:

```

<IfModule mod_proxy.c>

    ProxyRequests On

    <Proxy *>

        Order deny,allow

        Deny from all

        Allow from 127.0.0.1

        Allow from localhost

        Allow from 192.168.0.0/24

        Allow from 192.168.1.0/24

        Allow from 192.168.2.0/24

        Allow from fd05:efbb:4a1b::/64

    </Proxy>

    ProxyBlock zedo.com maxserving.com yieldmanager.com falkag.net serving-sys.com overture.com mediaplex.com zwire.com atwola.com advertising.com atwola.com hitbox.com doubleclick.net yimg.com specificclick.net tacoda.net overture.com adsonar.com pointroll.com unicast.com ytimg.com googlesyndication.com google-analytics.com quantserve.com pricegrabber.com checkm8.com clickability.com

    #

    # Enable/disable the handling of HTTP/1.1 "Via:" headers.

    # ("Full" adds the server version; "Block" removes all outgoing Via: headers)

    # Set to one of: Off | On | Full | Block

    #

   ProxyVia On

    #

    # To enable the cache as well, edit and uncomment the following lines:

    # (no caching without CacheRoot)

    #

    #LoadModule cache_module  modules/mod_cache.so

  <IfDefine CACHE>

    <IfModule mod_cache.c>

      #LoadModule disk_cache_module modules/mod_disk_cache.so

      CacheDefaultExpire 86400

      CacheMaxExpire 259200

#      CacheGcInterval 4

      CacheLastModifiedFactor 0.1

      #NoCache a-domain.com another-domain.edu joes.garage-sale.com

            <IfModule mod_disk_cache.c>

              CacheEnable disk /

              CacheRoot "/var/cache/apache2"

#             CacheSize 20000

              CacheMinFileSize 64

              CacheMaxFileSize 1000000

              CacheDirLength 2

              CacheDirLevels 5

            </IfModule>

              

    </IfModule>

  </IfDefine>

</IfModule>

# End of proxy directives.

```

----------

