Apache
Table of contents
Configure a proxy
Enable the http_proxy module
sudo a2enmod proxy_http
Create a VirtualHost, that looks somewhat like this:
<VirtualHost *:80>
ServerAdmin admin@gilgalab.com
ServerName subdomain.domain.com.br
ServerAlias subdomain.domain.com
ProxyPass "/" "http://localhost/"
ProxyPassReverse "/" "http://localhost/"
<Proxy *>
Authtype Basic
Authname "Authentication? What's that?"
AuthUserFile /etc/apache2/.htpasswd
Require valid-user
</Proxy>
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel debug
ErrorLog ${APACHE_LOG_DIR}/error_somedomain.log
CustomLog ${APACHE_LOG_DIR}/access_somedomain.log combined
</VirtualHost>
Add authentication to proxied website
Edit the website VirtualHost and add this:
<Proxy *>
Authtype Basic
Authname "Some message here"
AuthUserFile /etc/apache2/.htpasswd
Require valid-user
</Proxy>
Then create the .htpasswd file
sudo htpasswd -c /etc/apache2/.htpasswd username
Restart apache
sudo service apache2 restart