My curl
request looks as follows:
curl --header "Authorization: Basic BASE_64" https://example.com --tlsv1 -k
(I need to explicitly provide TLS
and skip verification)
and it works. I'd like to setup nginx
to act as middleware and handle authentication for remote server.
location / {
proxy_pass {{ remote_server }};
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Authorization "Basic {{ base64_token }}";
}
Unfortunately with these settings I got 403 forbidden. What I'm doing different than in curl
request?
My error.log
shows:
2014/12/20 02:40:12 [error] 15676#0: *13 connect() failed (111: Connection refused) while connecting to upstream, client: MY_OWN_IP, server: _, request: "GET /MY_REQUESTED_ENDPOINT HTTP/1.1", upstream: "https://MY_REMOTE_UPSTREAM", host: "MY_SERVER_IP"
2014/12/20 02:40:24 [info] 15676#0: *15 client timed out (110: Connection timed out) while waiting for request, client: MY_OWN_IP, server: 0.0.0.0:80
The very important thing is that MY_UPSTREAM
accepts connections only from MY_SERVER_UP
, that's why I'm creating this middleware.