Thanks, @ryanerwin! This was a big help. If you’re counting on /srv/status to work for some reason, your solution breaks it. Here’s how to allow /srv/status to be served without auth_basic.
# basic auth
- replace:
filename: "/etc/nginx/conf.d/discourse.conf"
from: "# auth_basic on"
to: "auth_basic on"
- replace:
filename: "/etc/nginx/conf.d/discourse.conf"
from: "# auth_basic_user_file /etc/nginx/htpasswd"
to: "auth_basic_user_file /etc/nginx/htpasswd"
- replace:
filename: "/etc/nginx/conf.d/discourse.conf"
from: "location = /srv/status {"
to: "location = /srv/status {
auth_basic off;"
- file:
path: "/etc/nginx/htpasswd"
contents: |
discourse:$apr1$y2JsCAxw$UuDgGdsoXNf.4Rl15Hp2b0
The above example is for user “discourse” and password “password”, though bad practice, we are just making sure that we get a password that a crawler won’t guess.
You can also generate a password something like this:
htpasswd -cb password_file user password
cat password_file