命令行安装
sudo apt-get install nginx
(缺少ssl)
开关
/etc/init.d/nginx start
/etc/init.d/nginx stop
编辑nginx.cono fig
cd /etc/nginx/
查看 cat nginx.conf
找出类似include /etc/nginx/conf.d/*.conf
;
在conf.d文件中创建*.conf
使编辑的文件生效
service nginx reload
内容如下:
//非真实IP
server {
listen 80;
server_name localhost;
location / {
proxy_pass http://localhost:8080; //修正,漏掉分号。
}
}
//真实IP
server {
listen 80;
server_name www.xxx.com;
location / {
proxy_pass http://115.159.143.193:8080;//后端ip地址
proxy_redirect off; //关闭后端返回的header修改
proxy_set_header Host $host; //修改发送到后端的header的host
proxy_set_header X-Real-IP $remote_addr; //设置真实ip
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
application.properties
server.tomcat.protocol_header=x-forwarded-proto
server.use-forward-headers=true
网友评论