HTTP Authentication through database

JaminVP nginx-forum at nginx.us
Thu Oct 22 12:17:02 UTC 2015


Whilst trying out the auth_request module I figured I could run a local php
file that connects to a database and checks if the user is valid.
I cannot figure out how to run the php script though, any ideas? This is my
nginx.conf:

events {
    worker_connections  10;
}

http {

	upstream elasticsearch {
    		server 127.0.0.1:9200;
  	}

    server {
	root    D:/ontw/tools/ELK-new/nginx-1.9.5/auth;
	listen 8080;
	location / {
		auth_request  /auth;
		proxy_pass http://elasticsearch;
      		proxy_http_version 1.1;
      
	}

	location = /auth {
    		proxy_pass $document_root/authentication.php;
    		proxy_pass_request_body off;
    		proxy_set_header Content-Length "";
    		proxy_set_header X-Original-URI $request_uri;
	}


	location ~ \.php$ {
		if (!-f $document_root$fastcgi_script_name){
			return 404;
		}
  		root    D:/ontw/tools/ELK-new/nginx-1.9.5/auth;
  		fastcgi_pass   127.0.0.1:9000;
  		fastcgi_index  index.php;
  		fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
  		include        fastcgi_params;
	}
    }
}

The authentication.php-script that should be run is located on 
D:/ontw/tools/ELK-new/nginx-1.9.5/auth. I don't know how to run it thoguh or
how I can see the output of the script. I have the pgp-cgi.exe running on
127.0.0.1:9000, waiting for connections.

I'm probably missing something, but I don't see it or understand it.

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,262394,262398#msg-262398



More information about the nginx mailing list