I have a spring boot application hosting restful services that sits behind an Nginx reverse proxy. The Nginx configuration lets accepts requests on http://mynginx/proxy/ and proxies them transparently to http://host/service/. The target service is secured and requires the Oauth token in the Authorization header. When I call the service directly using GET http://host/service it works as expected however. The same with different destination GET http://mynginx/proxy gives a 401 unauthorized HTTP response. I ultimately want to lock down my application so it is not publicly accessible so do not want to expose the target service directly. What do I need to do to get Authorization working through Nginx?
Here is my Nginx configuration for this service call
location /proxy/ {
proxy_pass http://host/service/;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $server_name;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Authorization $http_authorization;
proxy_pass_header Authorization;
}