nginx反向代理同一ip多个域名,给header加上host就可以了
- proxy_set_header Host $host;
nginx.conf例子
- upstream mysvr {
- server 127.0.0.1:8080;
- }
- server
- {
- listen 80;
- server_name servera.c1gstudio.com;
- index index.html index.htm index.php;
- root /opt/htdocs/www;
- location / {
- proxy_pass http://mysvr;
- proxy_set_header Host $host;
- proxy_set_header X-Real-IP $remote_addr;
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
- }
- }
- server
- {
- listen 80;
- server_name serverb.c1gstudio.com;
- index index.html index.htm index.php;
- root /opt/htdocs/www;
- location / {
- proxy_pass http://mysvr;
- proxy_set_header Host $host;
- proxy_set_header X-Real-IP $remote_addr;
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
- }
- }