Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question
    
What are you trying to accomplish? –  sciurus Apr 24 '13 at 1: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 8:21

1 Answer 1

up vote 0 down vote accepted

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;
}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.