On a development server, I have installed the tool Jenkins for automated testing. This runs on port 8080. If I go to www.mysite.com:8080
I can see the command panel for this. I want to make this inaccessible to the outside world by password protecting it using Apache. (My server is running Ubuntu 12.04 LTS). I read through the following page for general advice and specifically on the topic of security they suggest the following settings:
<VirtualHost *:80>
ServerAdmin your@email.address.com
DocumentRoot "/opt/apache/httpd/htdocs"
ServerName jenkins.yourdomain.com
ErrorLog "logs/jenkins-error_log"
ProxyPass /jenkins/ ajp://127.0.0.1:8102/jenkins/
ProxyPassReverse /jenkins/ ajp://127.0.0.1:8102/jenkins/
<Location />
Order allow,deny
Allow from all
</Location>
<Location /jenkins/>
AuthType basic
AuthName "jenkins"
AuthUserFile "/opt/apache/httpd/conf/.htpasswd"
</Location>
</VirtualHost>
My Apache file currently has the following settings:
<VirtualHost *:80>
# Admin email, Server Name (domain name), and any aliases
ServerAdmin tech@mysite.com
ServerName www.mysite.com
ServerAlias mysite.com
# Index file and Document Root (where the public files are located)
DirectoryIndex index.html index.php
DocumentRoot /var/www
# Log file locations
LogLevel warn
ErrorLog /var/log/apache/error.log
CustomLog /var/log/apache/access.log combined
</VirtualHost>
I could not get the suggested approach to work without an error (though no messages in console or in the logs), so I added the following lines:
<VirtualHost *:8080>
ServerName www.mysite.com
ProxyPass / http://www.dev.mysite.com:8080/
ProxyPassReverse / www.dev.mysite.com:8080/
ProxyPreserveHost on
<Proxy *>
AuthType Basic
AuthName "Dev Server"
AuthUserFile "/home/.htpasswd"
Require valid-user
</Proxy>
</VirtualHost>
And in my .htpasswd
file I put the following lines:
john:n5MfE
dave:9fluR
I then restarted Apache but port 8080
is still accesible without a password. Am I following the correct procedure?