Setting up Nginx — redirecting requests to a auth server and getting redirected back to serve the request

Anup asked:

Any incoming request on (x.x.x.x.x)–> redirect to — > that authenticates a user and redirects back to x.x.x.x server. (With a cookie set, In my case it is EZproxy server doing the cookie setting)

I have tried rewriting the request url and also using proxy_pass booth resulting in looping error error (from browser).

I must be missing some basic header or something i am not able to get what since yesterday morning.
Any suggestions regarding how the config must be?

My answer:

Your root directive has two problems:

  1. It uses a relative path. When a relative path is used, it’s relative to a default directory compiled into nginx. Do you know which one that is? It’s best to specify absolute paths.
  2. It is in the wrong place. The root directive should be specified in the server block. This is one of the most common nginx misconfigurations.

View the full question and any other answers on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.