Tags
webcam vindaloo vim version vegan unix unicef trojan todo tmux thinkpad textmate testing tagging syntax svn sugar subversion stubbing sphinx spam spaces solaris sitemap site sinatra shoulda sheet set security search schema_info SchemaInfo ruby rinari restaurant relationships refresh rdiff-backup ramaze railsconf08 railsconf07 rails protools production power placeboeffect pink floyd PIC perl overheat outbreak osx os x NYHS NYC nginx netbeans nested nanophotonics mysql music MPEG-4 mongrel model migration microvolunteer macbook mac logrotate logic log linux less leopard keynote JAX javascript java jacksonville iterm2 iterm imunizator highlighting hanna Handbrake haml hacks google geocoding genghistron gem gaming gabrielle's funny functional fun friends food fixesThe Decider said over 4 years ago permalink Comment? (0)
Tagged: rails mongrel ruby nginx
Protect Staging Server with Password
When developing a new application and releasing often you may want to protect the site from prying eyes. A simple way to do this when using the nginx web server is to use basic http authentication.
I prefer to do this in the nginx config file so it doesn’t impact local development.
You’ll need to create a password file using htpasswd command line utility. This file should be relative to the install directory of nginx. The default install would place this file in /usr/local/nginx
sudo htpasswd -cb /usr/local/this_hosts_password_file username passwordNext, you need to tell nginx to use basic auth for any access to this (virtual) host. I place the 2 relevant lines in the server portion of the config file
server { listen 80;- …
auth_basic “Login to see this alpha site.”;
auth_basic_user_file this_hosts_password_file; - …
}
A login will now be presented for any entry into the site.