Jéan
Jéan

Reputation: 657

Reverse Proxy with nginx: basic authentication on the proxy, but not to the backend server

I want to authenticate with basic auth on the proxy server (RPi), but do not want the proxy server to pass the auth info to the backend server.

Server 1 = 192.168.5.10 is the reverse proxy sevver, to which the router points to.
Server 2 = 192.168.5.30 is the server tht will serve the content back, but has not authentication on it.

Here are my settings:
--———--- /etc/nginx/sites-enabled/test.conf. ----——————

server {
listen 100;
location / {
proxy_pass http://192.168.5.30:100;
auth_basic "Login with xxx details";
auth_basic_user_file /etc/nginx/sites-available/pwd_file;
}

}

This allows me to authenticate successfully to Server 1, but Server 2 does not serve the content back, like it does when I do not have the auth_basic sections in.

How can I get basic auth working on server 1 but not let nginx pass the auth info to the 2ns server?

Upvotes: 1

Views: 4093

Answers (1)

anudeep
anudeep

Reputation: 413

You could try adding the below in the location block to tell nginx not to send authorization to the upstream,

proxy_set_header Authorization "";

Upvotes: 2

Related Questions