我有一个用作负载平衡器的站点。站点 A。
我有其他网站只能有一个域。所以如果我只是重定向到他们,它会说找不到主机名。
因此,如果我手动将标题设置为某些内容,则只会显示该站点。
如何设置proxy_set_header Host xxxx
为选择的服务器地址。这样,每个重新路由请求将具有不同且适当的主机标头。
如果我的其他 2 个站点可以基于 url 而不是主机头工作,那不会有问题。
worker_processes 1;
error_log logs/error.log;
error_log logs/error.log notice;
error_log logs/error.log info;
error_log logs/error.log debug;
pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
upstream myapp1 {
#server localhost:3333;
server www.asd.com:80;
}
server {
listen 80;
location / {
proxy_set_header Host $upstream_addr; // should become somehow www.asd.com right now this code doesn't work
proxy_set_header X-Forwarded-For $remote_addr;
proxy_pass http://myapp1;
}
}
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
44154 次 |
最近记录: |