How to send request to proxy pass url based on server name in nginx?

g13 asked:

I have subdomains and Below is my configuration:

server {
 listen 80;

 location / {

This is giving error like

“no resolver defined to resolve…”

Is it possible to send proxy pass url based on server name or am I missing something?

My answer:

You’re trying to proxy requests to But you haven’t defined as an upstream, so nginx treats it as a hostname to look up and connect to. But you don’t have a DNS resolver defined anywhere.

To fix the problem, do one of those two things.

View the full question and answer on Server Fault.

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