nginx

命令行安装

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
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容