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

My question is in the subj. I have a one domain, that's nginx's config of it:

server {
listen 80;
server_name connect3.domain.ru www.connect3.domain.ru;

access_log /var/log/nginx/connect3.domain.ru.access.log;
error_log /var/log/nginx/connect3.domain.ru.error.log;

root /home/httpd/vhosts/html;
index index.html index.htm index.php;

location ~* \.(avi|bin|bmp|css|dmg|doc|docx|dpkg|exe|flv|gif|htm|html|ico|ics|img|jpeg|jpg|js|m2a|m2v|mov|mp3|mp4|mpeg|mpg|msi|pdf|pkg|png|pps|ppt|pptx|ps|rar|rss|rtf|swf|tif|tiff|txt|wmv|xhtml|xls|xml|zip)$ {
    root /home/httpd/vhosts/html;
    access_log off;
    expires 1d;
}

location ~ /\.(git|ht|svn) {
    deny all;
}

location / {
    #rewrite ^ http://connect2.domain.ru/;
    proxy_pass http://127.0.0.1:8080/;
    proxy_redirect off;
    proxy_hide_header "Cache-Control";
    add_header Cache-Control "no-store, no-cache, must-revalidate, post-check=0, pre-check=0";
    proxy_hide_header "Pragma";
    add_header Pragma "no-cache";
    expires -1;
    add_header Last-Modified $sent_http_Expires;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}

I need to proxy connect3.domain.ru host to connect2.domain.ru, but with no URL changed in browser's address bars. My commented out rewrite line could solve this problem, but it's just a rewrite, so I cannot stay with the same URL.

I know that this question is easy, but please help. Thank you.

share|improve this question

3 Answers 3

up vote 2 down vote accepted

You set:

proxy_set_header Host $host;

You want:

proxy_set_header Host connect2.domain.ru;
share|improve this answer
    
And that's all? Need I change proxy_pass 127.0.0.1:8080; to proxy_pass connect2.domain.ru:8080; ? Or just comment out rewrite as it is and change proxy_set_header? –  Evgeniy Yablokov Jun 8 '12 at 4:31
    
Tried this. No, URL changes. –  Evgeniy Yablokov Jun 8 '12 at 4:46
    
Or just comment out rewrite as it is and change proxy_set_header? Yeap. –  VBart Jun 8 '12 at 7:15

So I think - here is the solution if I understood the problem correctly:

 # backend.wants.this.server.com
 # browser.shows.this.server.com

server {
  listen 80;
  server_name browser.shows.this.server.com;

  location / {
     proxy_set_header Host backend.wants.this.server.com;
     proxy_redirect http://backend.wants.this.server.com/ http://browser.shows.this.server.com/; 
  }
}
share|improve this answer

Telepathy about port 8080 has been turned off, because you don't show us the full config.

server {
    listen 80;
    server_name connect3.domain.ru www.connect3.domain.ru;

    location / {
        proxy_pass http://connect2.domain.ru;
        proxy_set_header Host connect2.domain.ru;
    }
}
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.