nginx配置文件
- 负载均衡
upstream sess {
ip_hash;
server backend1.example.com;
server backend2.example.com;
}
server {
listen 80;
server_name www.session.com;
location / {
proxy_pass http://sess;
proxy_set_header Host $http_host;
}
}
- 反向代理 (服务器端做手脚)
server {
listen 80;
server_name www.123.com;
location / {
proxy_pass http://127.0.0.1:8080;
proxy_set_header Host $host; # 设置后端服务器接收到的Host头为原始请求的Host
proxy_set_header X-Real-IP $remote_addr; # 设置X-Real-IP头为客户端的IP地址
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; #用来表示HTTP请求端真实IP
index index.html index.htm index.jsp;
}
}
- 代理 客户端做手脚
本文来自博客园,作者:小二jerry,转载请注明原文链接:https://www.cnblogs.com/jassonWang/p/18884618