Welcome! Log In Create A New Profile

Advanced

Re: Using Nginx auth in PHP scripts

All files from this thread

File Name File Size   Posted by Date  
smime.p7s 6 KB open | download GreenGecko 02/26/2013 Read message
smime.p7s 6 KB open | download GreenGecko 02/26/2013 Read message
B.R.
February 26, 2013 05:28PM
Thanks to both of you, I got the info I was seeking for.

However, when I try to activate the fastcgi_param, the content doesn't seem
to reach PHP anymore.
No error logged neither in Nginx nor PHP it seems.
I feel like I am a noob... oO

server {
listen 80;
server_name ~ab.cd$;
root /var/web/$host;
index index.html index.php;
try_files $uri $uri/ =404;
access_log /var/log/nginx/ab.cd/access.log main;
error_log /var/log/nginx/ab.cd/error.log warn;
include conf.d/includes/fastcgi.conf;
auth_basic "Get out!";
auth_basic_user_file /var/web/ab.cd.htpasswd;

location ~ \.php$ {
fastcgi_pass unix:/var/run/php-fpm.sock;

#If the following is activated, no more PHP output...
Something is wrong
# fastcgi_param MY_GREAT_USER $remote_user;
}
}

---
*B. R.*


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

> It's my understanding the $remote_user is available.
>
> Sorry, a poor example. Could have used one that answers your question
> directly...
>
> Steve
>
> On Tue, 2013-02-26 at 16:23 -0500, B.R. wrote:
> > Thanks, I learned something there.
> >
> > But does the auth_basic module 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@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@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@nginx.org
> > http://mailman.nginx.org/mailman/listinfo/nginx
> >
> >
> > _______________________________________________
> > nginx mailing list
> > nginx@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@nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx
>
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Using Nginx auth in PHP scripts

B.R. February 26, 2013 04:00PM

Re: Using Nginx auth in PHP scripts Attachments

GreenGecko February 26, 2013 04:16PM

Re: Using Nginx auth in PHP scripts

B.R. February 26, 2013 04:26PM

Re: Using Nginx auth in PHP scripts

Francis Daly February 26, 2013 04:32PM

Re: Using Nginx auth in PHP scripts

B.R. February 26, 2013 11:40PM

Re: Using Nginx auth in PHP scripts Attachments

GreenGecko February 26, 2013 04:32PM

Re: Using Nginx auth in PHP scripts

B.R. February 26, 2013 05:28PM

Re: Using Nginx auth in PHP scripts

Francis Daly February 26, 2013 05:36PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 138
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