python - Django: Use htaccess to protect django app -


i have staging server identical source code production server. want keep public outside of staging server thought of using htaccess limit users staging server (and keep robots , strangers outside).

somehow not working me.

i created passwordfile

sudo htpasswd -cs /var/.passwd staging 

i placed .htaccess file in

/var/www/djangoapp/ 

.htaccess:

authuserfile /var/.passwd authtype basic authname "just testing" require valid-user 

i ensured:

<directory /var/www/>     options indexes followsymlinks     allowoverride     require granted </directory> 

apache restart:

sudo service apache2 restart 

the django application still available everybody. doing wrong?

i found alternative solution above goal without htaccess. share:

in 000-default-conf in respective virtualhost section:

<directory /var/www/djangoapp/djangoapp>         authuserfile /var/.htpasswd         authname "just testing"         authtype basic         require valid-user          <files wsgi.py>             require valid-user         </files>         wsgiapplicationgroup %{global} </directory> 

of course solution works if have access config file on server. anyway solved issue. not figure out why original setup in question not working me.


Comments

Popular posts from this blog

sequelize.js - Sequelize group by with association includes id -

android - Robolectric "INTERNET permission is required" -

java - Android raising EPERM (Operation not permitted) when attempting to send UDP packet after network connection -