spiritedmedia / systems

Code and documentation for building, deploying, and serving code.
1 stars 1 forks source link

Make Two Scripts for Turning Basic Auth On/Off on Staging Server #44

Open kingkool68 opened 6 years ago

kingkool68 commented 6 years ago

There are times when we need external services to test our pages (like Twitter reading our social graph meta data in the HTML) and basic auth blocks that from happening. A simple way to temporarily turn off basic auth would be nice.

We can do this manually by editing /var/www/staging.spiritedmedia.com/conf/nginx/site.conf and editing the following lines:

# To turn off basic auth, uncomment the following line
set $auth_basic off;
auth_basic $auth_basic;
auth_basic_user_file /var/www/staging.spiritedmedia.com/conf/nginx/.htpasswd;

set $auth_basic off; means no basic auth # set $auth_basic off; means basic auth

Then we need to restart nginx for the changes to take effect: sudo ee stack restart --nginx

kingkool68 commented 6 years ago

If I wanted to experiment with sed it would probably be pretty easy. Then we can set-up a cron job to run the script to turn on basic auth every 12 hours or so because humans can be forgetful.