Thomas Ward
March 19, 2020 08:36PM
You can specify different auth_basic configurations per server or per
location match.

Refer to the documentation -
http://nginx.org/en/docs/http/ngx_http_auth_basic_module.html - which
shows that the auth_basic config options can be at the http, server,
location, or limit_except levels of the configuration.  You can
configure different server hostnames or locations within the same server
block.

Example configuration - different auth sets per location path within the
foo.example.com auth AND a site config that will have a completely
separate third auth that covers an entire site (private.example.com)
(note that both of these server definitions are implied to be in an http
server block, I just am not typing it out here for brevity)

server {

    listen 80;

    server_name foo.example.com;

    location /foo/ {

        try_files $uri $uri/ =403;

        auth_basic on;

        auth_basic_user_file /etc/nginx/fooauths;

    }

    location / {

        try_files $uri $uri/ =403;

        auth_basic on;

        auth_basic_user_file /etc/nginx/rootauths;

    }

}

server {

    listen 80;

    server_name private.example.com;

    auth_basic on;

    auth_basic_user_file /etc/nginx/privateauths;

    location / {

        try_files $uri $uri/ =403;

    }

}


Thomas


On 3/19/20 11:23 AM, Roberto Carna wrote:
> Hi people, 
>
> I wanna use NGINX as a SSL reverse proxy for several backends Apache
> web servers which listens on port TCP/8080 and TCP/9090.
>
> The NGINX reverse proxy must have one independent authentication for
> each backend web server:
>
> NGINX -- Auth 1 --- Web server 1 ports 8080/9090
>             -- Auth 2 --- Web server 2 ports 8080/9090
>             -- Auth 3 --- Web server 3 ports 8080/9090
>              etc.
>
> Is it possible to do this???
>
> Can you give me some info o link in this way ???
>
> Thanks a lot and regards !!!
>
> _______________________________________________
> 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

Nginx SSL reverse proxy with independent authentication for each backend web server

Roberto Carna March 19, 2020 11:26AM

Re: Nginx SSL reverse proxy with independent authentication for each backend web server

Thomas Ward March 19, 2020 08:36PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

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