dbembibre
Active member
Hi to all im totally stucked with a stupid thing, i move in my plesk nginx as reverse proxy for apache to nginx server directly php files via php-fpm, all work ok, xenforo url friendly, etc. But i can't make a password protected directory, i see that auth basic module is part of the core of nginx.
My nginx.com
	
	
	
		
				
			My nginx.com
		Code:
	
	server {
    listen x.x.x.x:80;
    server_name site.com;
    server_name www.site.com;
    server_name ipv4.site.com;
    client_max_body_size 128m;
    root "/var/www/vhosts/site.com/httpdocs";
    location / {
        proxy_pass http://x.x.x.x:7080;
        proxy_set_header Host            $host;
        proxy_set_header X-Real-IP        $remote_addr;
        proxy_set_header X-Forwarded-For  $proxy_add_x_forwarded_for;
        access_log off;
        try_files $uri $uri/ /index.php?$uri&$args;
    }
    location ~ /(internal_data|library) {
        internal;
    }
    location @[USER=7374]FallBack[/USER] {
        proxy_pass http://x.x.x.x:7080;
        proxy_set_header Host            $host;
        proxy_set_header X-Real-IP        $remote_addr;
        proxy_set_header X-Forwarded-For  $proxy_add_x_forwarded_for;
        access_log off;
    }
    location ~ ^/(.*\.(ac3|avi|bmp|bz2|css|cue|dat|doc|docx|dts|exe|flv|gif|gz|htm|html|ico|img|iso|jpeg|jpg|js|mkv|mp3|mp4|mpeg|mpg|ogg|pdf|png|ppt|pptx|qt|rar|rm|swf|tar|tgz|txt|wav|xls|xlsx|zip))$ {
        try_files $uri @[USER=7374]FallBack[/USER];
    }
    location ~ ^/~(.+?)(/.*)?$ {
        proxy_pass http://x.x.x.x:7080;
        proxy_set_header Host            $host;
        proxy_set_header X-Real-IP        $remote_addr;
        proxy_set_header X-Forwarded-For  $proxy_add_x_forwarded_for;
        access_log off;
    }
    location /protected_directory {
        auth_basic  "protected directory";
        auth_basic_user_file  /var/www/vhosts/system/site.com/pd/filewithpassword;
}
  location ~ ^/admin/.*\.php$ {
        auth_basic  "";
      auth_basic_user_file  /var/www/vhosts/system/site.com/pd/filewithpassword;
    proxy_pass http://x.x.x.x:7080;
        proxy_set_header Host            $host;
        proxy_set_header X-Real-IP        $remote_addr;
        proxy_set_header X-Forwarded-For  $proxy_add_x_forwarded_for;
}
    location ~ \.php(/.*)?$ {
        fastcgi_split_path_info ^((?U).+\.php)(/?.+)$;
        fastcgi_param PATH_INFO $fastcgi_path_info;
        fastcgi_pass "unix:/var/www/vhosts/system/site.com/php-fpm.sock";
        include /etc/nginx/fastcgi.conf;    }
    location ~ /$ {
        try_files $uri $uri/ /index.php?$uri&$args;
        index index.php index.html index.htm index.cgi index.xhtml index.pl index.shtml;
    }
}
			
				Last edited: 
			
		
	
								
								
									
	
								
							
							 
 
		 
 
		
 
 
		 
 
		 
 
		 
 
		 
 
		