<div dir="ltr">I want to authorize requests using a remote server that is using ssl. When I make requests with https I get nginx errors but when I use http it works. Now that I am writing this I'm thinking the issue is that the site isn't using ssl so that could cause proxy pass fails. <div>
<br></div><div>Thanks in advance!</div><div><br></div><div>Aaron<br><div><br></div><div><div>$ tail /var/log/nginx/error.log </div><div>2014/05/15 20:49:52 [error] 19355#0: *1 invalid URL prefix in "<a href="https://iam.ids.enernoc.net/api/v1/key/validation?permissions=dataset_DATQUAL1_read">https://iam.ids.enernoc.net/api/v1/key/validation?permissions=dataset_DATQUAL1_read</a>", client: 10.100.1.157, server: localhost, request: "GET /api/v1/dataset/DATQUAL1?ids=17228629&start_dttm=1382486700&end_dttm=1382573100&gran=fivemin&ts_format=iso-8601&resp_format=json HTTP/1.1", subrequest: "/iams_auth", host: "10.160.1.52"</div>
<div>2014/05/15 20:49:52 [error] 19355#0: *1 auth request unexpected status: 500 while sending response to client, client: 10.100.1.157, server: localhost, request: "GET /api/v1/dataset/DATQUAL1?ids=17228629&start_dttm=1382486700&end_dttm=1382573100&gran=fivemin&ts_format=iso-8601&resp_format=json HTTP/1.1", host: "10.160.1.52"</div>
<div><br></div><div>Ubuntu 14 LTS</div><div>Nginx info</div><div>$ /opt/nginx-1.6.0/sbin/nginx -V</div><div>nginx version: nginx/1.6.0</div><div>built by gcc 4.8.2 (Ubuntu 4.8.2-19ubuntu1) </div><div>configure arguments: --prefix=/opt/nginx-1.6.0 --conf-path=/etc/nginx/nginx.conf --sbin-path=/opt/nginx-1.6.0/sbin/nginx --with-http_auth_request_module</div>
</div><div><br></div><div>server block:</div><div>server {</div><div> </div><div> listen 80; ## listen for ipv4; this line is default and implied</div><div> server_name localhost;</div><div><br></div><div>
gzip on;</div><div><br></div><div> # authorization key to use with iam. set this to a default valid key.</div><div> set $valid_key "Basic ZjNqejZNZlZTVDZuNWpjQjhLcEVkWXd3TnJqeng1VnJQQ0FYYU03V3pCY2dMU0F4Og==";</div>
<div> set $iams_server "<a href="https://iam.ids.enernoc.net/api/v1/key/validation">https://iam.ids.enernoc.net/api/v1/key/validation</a>"</div><div><br></div><div> location ~ ^/api/v1/dataset {</div><div> if ($request_method != GET) {</div>
<div> set $auth_request_uri "?permissions=create_dataset";</div><div> }</div><div> if ($request_method = GET) {</div><div> set $auth_request_uri "?permissions=list_dataset";</div>
<div> }</div><div><br></div><div> auth_request /iams_auth;</div><div><br></div><div> proxy_set_header Host $http_host;</div><div> proxy_redirect off;</div><div> proxy_set_header Server-Addr $server_addr;</div>
<div><br></div><div> proxy_pass <a href="http://app_server">http://app_server</a>;</div><div> }</div><div><br></div><div> location /iams_auth {</div><div> resolver 10.160.0.2;</div><div> proxy_pass $iams_server$auth_request_uri;</div>
<div> proxy_pass_request_body off;</div><div> proxy_set_header Content-Length "";</div><div> proxy_set_header X-Original-URI $request_uri;</div><div> # We would like to use authentication but not enforce it upon our users immediately, therefore...</div>
<div> # If the user does not provide basic authorization we will use the default valid key variable.</div><div> # If the user does provide basic auth, pass that value along instead of the default valid key.</div>
<div> if ($remote_user != ''){</div><div> set $valid_key $http_authorization;</div><div> }</div><div> proxy_set_header Authorization $valid_key;</div><div> proxy_pass_request_headers on;</div>
<div> }</div><div>}</div><div><br></div><div><div>upstream app_server {</div><div><br></div><div> server unix:/tmp/ids-api.sock;</div><div>}</div></div></div></div>