反向代理获取不到用户真实ip

  1. 昨天讲公司活动项目发布到线上环境,但是测试的时候发现抽奖者的ip一直是127.0.0.1,还以为是自己的代码的问题,但是开发环境是内网的,因此想用手机端外网访问,但是外网访问不了内网的.于是开始折腾了.
    1. 下载了ngork软件,好像这款软件可以进行代理供外部客户端访问.于是很简单的下载linux版本并运行,运行灰常简单.只要输入命令ngrok 加上自己web项目运行的端口号就可以进行外部访问了
    donghual@lifeix:~/java$ ngrok 8080
    ngrok                                                           (Ctrl+C to quit)
                                                                                    
    Tunnel Status                 online                                            
    Version                       1.6/1.6                                           
    Forwarding                    http://2e8992f2.ngrok.com -> 127.0.0.1:8080       
    Forwarding                    https://2e8992f2.ngrok.com -> 127.0.0.1:8080      
    Web Interface                 127.0.0.1:4040                                    
    # Conn                        69                                                
    Avg Conn Time                 2957.27ms                                         
                                                                                    
    
    
    HTTP Requests                                                         
    -------------                                                         
                                                                          
    GET /activity/doubi/prize/era 200 OK                                  
    GET /activity/doubi/prize/era 200 OK                                  
    GET /activity/doubi/prize/era 200 OK                                  
    GET /activity/doubi/prize/era 200 OK                                  
    GET /activity/doubi/prize/era 200 OK                                  
    GET /images/picture_cover.png 200 OK                                  
    GET /images/hb_bg.png         200 OK                                  
    GET /activity/doubi/prize/sta 200 OK                                  
    GET /images/dianwoshishi_02.p 200 OK

            b. 外网访问http://2e8992f2.ngrok.com就可以访问到你的内网部署项目了

            c.于是开始调试了,在运行到获取ip的代码后发现获取的确实是127.0.0.1,但我在内网测试的情况不会发生,因此可以得到一个结论,线上环境和本地环境只是多了nginx,那么肯定是nginx这边有问题.于是去叫运维帮忙配置下了.

    


            


你可能感兴趣的:(nginx,Ngrok)