Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've upstream in my http block:

upstream {

And within the frontend's server block:

location ~* ^/special {
    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
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 {

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
    include /etc/nginx/conf.d/proxy.conf;
share|improve this answer

Your Answer


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.