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

Thomas Ward teward at thomas-ward.net
Fri Mar 20 00:34:18 UTC 2020


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 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/20200319/64bad714/attachment.htm>


More information about the nginx mailing list