網頁

2016年7月12日 星期二

Nginx Reverse proxy from VirtualHost to VirtualHost

www.demo.com DNS is go to Server1. /and Reverse proxy to Server2 by server2.demo.com . But Server2 need to known www.demo.com. So we need set header by proxy_set_header.

**Server1**
```
server {
  listen 80;
  server_name www.demo.com;

  location / {
      proxy_set_header Host $host;
      proxy_pass http://server2.demo.com/;
  }
}

```


**Server2 server2.demo.com**
```
server {
    listen 80;
    server_name www.demo.comt;
    root /opt/www/;
    index index.html index.htm;
}
```

沒有留言: