LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-18-2019, 03:44 AM   #16
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 12,410

Rep: Reputation: 1727Reputation: 1727Reputation: 1727Reputation: 1727Reputation: 1727Reputation: 1727Reputation: 1727Reputation: 1727Reputation: 1727Reputation: 1727Reputation: 1727

In this case better put the auth stuff outside the location block, so it applies globally:
Code:
http {
    access_log 		logs/http_access.log;
    include       	mime.types;
    default_type  	application/octet-stream;
    sendfile        	on;
    keepalive_timeout  	65;
		
    server {
        listen		80;
        server_name	localhost;

	auth_basic "Restricted Content";
	auth_basic_user_file /usr/local/nginx/conf/.htpasswd; 

     # rtmp statistics
        location /stat {
            rtmp_stat all;
            rtmp_stat_stylesheet stat.xsl;
            allow 127.0.0.1;
        }
<-SNIP->
        location / {
	    index index.html index.htm index.php index.cgi;
	}
<-SNIP->
 
2 members found this post helpful.
Old 03-19-2019, 01:42 AM   #17
regstuff
LQ Newbie
 
Registered: Oct 2018
Distribution: Ubuntu 16.04
Posts: 17

Original Poster
Rep: Reputation: Disabled
Thank you very much. That worked!
Quote:
Originally Posted by bathory View Post
In this case better put the auth stuff outside the location block, so it applies globally:
Code:
http {
    access_log 		logs/http_access.log;
    include       	mime.types;
    default_type  	application/octet-stream;
    sendfile        	on;
    keepalive_timeout  	65;
		
    server {
        listen		80;
        server_name	localhost;

	auth_basic "Restricted Content";
	auth_basic_user_file /usr/local/nginx/conf/.htpasswd; 

     # rtmp statistics
        location /stat {
            rtmp_stat all;
            rtmp_stat_stylesheet stat.xsl;
            allow 127.0.0.1;
        }
<-SNIP->
        location / {
	    index index.html index.htm index.php index.cgi;
	}
<-SNIP->
 
  


Reply

Tags
htaccess, nginx


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Apache htaccess RewriteRule to Nginx gubak Linux - Server 1 11-18-2015 02:47 AM
nginx + php-fpm and nginx modules fantasygoat Linux - Server 0 06-09-2011 12:21 PM
checkpassword only works as root, authentication with spamdyke, qmail dbj Linux - Server 1 10-15-2009 12:57 AM
Apache authentication (.htaccess) password reset page hattori.hanzo Linux - Newbie 0 11-05-2008 12:01 AM
RH & HP4050N PCL - page, pause, page, pause, page andguent Linux - Hardware 0 11-10-2003 08:35 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:55 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration