2

I would like to set the auth_basic globally for all the projects with nginx.

It works well by setting in on every project conf with:

auth_basic "DEV restricted access";
auth_basic_user_file /var/www/passwd;

In order to avoid this to be forgot for new projects, I would like to set this globally. Is it possible?

2 Answers 2

3

According to the manual, auth_basic can be configured globally by placing the commands within the http block.

Depending on your particular flavour of OS, start with the master nginx.conf configuration file, and find the http { ... } section or possibly an auxiliary configuration file which is pulled into it using an include statement.

Sign up to request clarification or add additional context in comments.

1 Comment

Work as a charm. Thanks a lot.
0

Create file:

/etc/nginx/conf.d/pick-your-name.conf

and put there this piece of text:

auth_basic "DEV restricted access";
auth_basic_user_file /var/www/passwd;

Works the same as placing it straight into nginx.conf but keeps your configuration clean.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.