# adding mod_proxy (vhost + proxypass)

## chenko

Firstly -D PROXY is included...

```

# cat /etc/conf.d/apache2 | grep APACHE2_OPTS=

APACHE2_OPTS="-D DEFAULT_VHOST -D INFO -D SSL -D SSL_DEFAULT_VHOST -D LANGUAGE -D PROXY"

```

apache starts without errors but -t gives this...

```

# apache2 -t

Syntax error on line 2 of /etc/apache2/vhosts.d/01_sabnzbd_vhost.conf:

Invalid command 'ProxyPreserveHost', perhaps misspelled or defined by a module not included in the server configuration

```

I recompiled using USE=proxy then realised I need to set APACHE2_MODULES=proxy, doing that looks like it tries to block a load of modules... (I set apache2_modules in make.conf)

```

 # APACHE2_MODULES="proxy" emerge --pretend --newuse --deep --update -v world

These are the packages that would be merged, in order:

Calculating dependencies... done!

[ebuild   R   ] www-servers/apache-2.2.14-r1  USE="ldap ssl -debug -doc (-selinux) -static -suexec -threads" APACHE2_MODULES="proxy -actions* -alias* -asis -auth_basic* -auth_digest -authn_alias* -authn_anon* -authn_dbd -authn_dbm* -authn_default* -authn_file* -authz_dbm* -authz_default* -authz_groupfile* -authz_host* -authz_owner* -authz_user* -autoindex* -cache* -cern_meta -charset_lite -dav* -dav_fs* -dav_lock* -dbd -deflate* -dir* -disk_cache* -dumpio -env* -expires* -ext_filter* -file_cache* -filter* -headers* -ident -imagemap -include* -info* -log_config* -log_forensic -logio* -mem_cache* -mime* -mime_magic* -negotiation* -proxy_ajp -proxy_balancer -proxy_connect -proxy_ftp -proxy_http -rewrite* -setenvif* -speling* -status* -substitute -unique_id* -userdir* -usertrack* -version -vhost_alias*" APACHE2_MPMS="-event -itk -peruser -prefork -worker" 0 kB

Total: 1 package (1 reinstall), Size of downloads: 0 kB

```

```

* Module 'authz_host' is required in the default apache configuration.

 * Module 'dir' is required in the default apache configuration.

 * Module 'mime' is required in the default apache configuration.

 *

 * You have disabled one or more required modules

 * for the default apache configuration.

 * Although this is not an error, please be

 * aware that this setup is UNSUPPORTED.

```

Compiling shows this - am I going to have to list all the modules I need (the ones that were previously included by default)?

I try to get around this by using APACHE2_MODULES="proxy $APACHE2_MODULES"

```

 # emerge --ask --newuse --deep --update -v world

These are the packages that would be merged, in order:

Calculating dependencies... done!

[ebuild   R   ] www-servers/apache-2.2.14-r1  USE="ldap ssl -debug -doc (-selinux) -static -suexec -threads" 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* proxy rewrite* setenvif* speling* status* unique_id* userdir* usertrack* vhost_alias* -asis -auth_digest -authn_dbd -cern_meta -charset_lite -dbd -dumpio -ident -imagemap -log_forensic -proxy_ajp -proxy_balancer -proxy_connect -proxy_ftp -proxy_http -substitute -version" APACHE2_MPMS="-event -itk -peruser -prefork -worker" 0 kB

Total: 1 package (1 reinstall), Size of downloads: 0 kB

```

I'm trying to set a vhost that is just a proxy, and I used the example from the Apache site.

```

<VirtualHost *:80>

ProxyPreserveHost On

ProxyPass /sabnzb http://localhost:port/

ProxyPassReverse /sabnzb http://localhost:port/

ServerName server

</VirtualHost>

```

httpd.conf includes

```

<IfDefine PROXY>

LoadModule proxy_module modules/mod_proxy.so

</IfDefine>

```

http://server/sabnzb/ - gives a 500 Internal server error

http://server/ - give "You don't have permission to access / on this server." error (without the vhost enabled it works fine).

Should I be using proxy_ajp and proxy_http?

Added them both and now httpd.conf includes this

```

<IfDefine PROXY>

LoadModule proxy_module modules/mod_proxy.so

</IfDefine>

<IfDefine PROXY>

LoadModule proxy_ajp_module modules/mod_proxy_ajp.so

</IfDefine>

<IfDefine PROXY>

LoadModule proxy_http_module modules/mod_proxy_http.so

</IfDefine>

```

now /sabnzb/ works (though no sub-directories) but / still doesn't.

What is the "proper" way of including the mod_proxy module? I don't want to risk messing around too much only for something to break later on :/

----------

