配置nginx代理tomcat,配置如下:
upstream tomcat {
server 127.0.0.1:8080;
}
server {
listen 80;
server_name test.geekapp.cn;
location / {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
#以上4句是可以使客户端真实ip,否则被代理服务获取的IP是127.0.0.1
proxy_pass http://tomcat;
}
}