WebFaction
Community site: login faq

Hello

How do I password protect my site with HTTP Basic Authentication in nginx?

I've read that I can add this to nginx.conf, however when I restart the server I get an error "location" directive not allowed here.

location / {
    auth_basic            "Restricted";
    auth_basic_user_file  \home\username\webapps\otherapp\.htpasswd;
}

Where do I put this directive?

asked 12 Nov '13, 15:32

turgs
7410
accept rate: 0%


According to the Nginx docs, location needs to be inside of a server block, or within another location directive (itself inside of a server block).

permanent link

answered 12 Nov '13, 15:56

seanf
12.2k41836
accept rate: 37%

edited 12 Nov '13, 15:57

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×186
×31
×29
×3

question asked: 12 Nov '13, 15:32

question was seen: 3,116 times

last updated: 12 Nov '13, 15:57

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2019 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM