0

I've upstream in my http block:

upstream backend.example.com {
    server 127.0.0.1:443;
}

And within the frontend's server block:

location ~* ^/special {
    proxy_pass https://backend.example.com;
    include /etc/nginx/conf.d/proxy.conf;
}

This appears to work fine when backend.example is hosted by Apache or is on another box. When frontend and backend are "virtual hosts" listening at the same address and port, Nginx returns a 502 Bad Gateway (misconfiguration) error.

Is Nginx capable of proxying to itself, and resolving its destination based on the server name?

David Hodnett
  • 139
  • 2
  • 6
  • What are you trying to accomplish? – sciurus Apr 24 '13 at 01:40
  • @sciurus i needed to do this for a few things like when i need to serve a staic file and the user sends me post data you proxy pass to the same machine but change the type to get in that proxy its not as effecant as we would like it to be but works. – WojonsTech Apr 24 '13 at 08:21

1 Answers1

0

From what I can see you should try renaming your backend upstream lets try something like this.

upstream backend {
   server 127.0.0.1:443;
}

Now when you are trying to do the proxypass lets change it to the new upstream name and then set a different header

location ~* ^/special {
    proxy_pass https://backend;
    proxy_set_header Host backend.example.com
    include /etc/nginx/conf.d/proxy.conf;
}
WojonsTech
  • 350
  • 1
  • 10