Using Nginx auth in PHP scripts

B.R. reallfqq-nginx at yahoo.fr
Tue Feb 26 21:23:14 UTC 2013


Thanks, I learned something there.

But does the auth_basic
module<http://nginx.org/en/docs/http/ngx_http_auth_basic_module.html>allows
you to load the username in a Nginx variable?
>From what I understand everything is processed internally.

---
*B. R.*


On Tue, Feb 26, 2013 at 4:15 PM, Steve Holdoway <steve at greengecko.co.nz>wrote:

> You can pass environment vars to PHP no problem...
>
> Eg: if you set up geoip in nginx.conf
>
> geoip_country           /usr/share/GeoIP/GeoIP.dat;
>
> this makes $geoip_country_code available to your nginx config.
>
> If you then set
> fastcgi_param GEOIP_COUNTRY_CODE $geoip_country_code;
>
> then
>
> $_SERVER['GEOIP_COUNTRY_CODE'] is then available to php.
>
> This can be done for any variable set within nginx.
>
> hth,
>
> Stve
>
>
> On Tue, 2013-02-26 at 15:58 -0500, B.R. wrote:
> > Hello,
> >
> >
> > The only information I got on the Web was to protect folders with
> > Nginx auth, just like the plein old Apache's .htaccess.
> >
> >
> > I am already using AuthPlain to secure a folder with Nginx, using PHP
> > scripts inside.
> >
> > I wonder if it was possible to use Nginx auth information inside those
> > PHP scripts.
> >
> >
> > More precisely, I would have a directory protected with AuthPlain and
> > I would have a script (let's call it index.php) being called when the
> > authentication is successful.
> >
> > The AuthPlain has several users registered and I would like to know if
> > index.php might be aware who logged in to welcom him with his/her
> > username.
> >
> >
> > Am I dreaming too much ?
> > ---
> > B. R.
> > _______________________________________________
> > nginx mailing list
> > nginx at nginx.org
> > http://mailman.nginx.org/mailman/listinfo/nginx
>
> --
> Steve Holdoway BSc(Hons) MIITP
> http://www.greengecko.co.nz
> Skype: sholdowa
>
> _______________________________________________
> nginx mailing list
> nginx at nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20130226/12db54bd/attachment-0001.html>


More information about the nginx mailing list