Welcome! Log In Create A New Profile

Advanced

Re: ngx_http_auth_request и fastcgi

VovansystemS
August 25, 2017 07:30AM
а, кажется разобрался. так работает:

location = /test.php {
auth_request /is_proxy.php;
fastcgi_pass fcgi_pool;
}

location = /is_proxy.php {
fastcgi_pass_request_body off;
fastcgi_intercept_errors off;
fastcgi_pass fcgi_pool;
}

cat is_proxy.php
<?php

if (!empty($_SERVER['REMOTE_ADDR'])) {

$ip=$_SERVER['REMOTE_ADDR'];

$url="http://someservice.com/check.php?ip=$ip";

$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL,$url);
$result=curl_exec($ch);
curl_close($ch);

echo($ip);

if ($result === 'Y') {
http_response_code(403);
} else {
http_response_code(200);
}

} else {
//failsafe
http_response_code(200);
}
_______________________________________________
nginx-ru mailing list
nginx-ru@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-ru
Subject Author Posted

ngx_http_auth_request и fastcgi

VovansystemS August 25, 2017 06:56AM

Re: ngx_http_auth_request и fastcgi

VovansystemS August 25, 2017 07:30AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 124
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready