How to get proxy value of nginx-key X-Real-IP in Ratchet websocket

i'm setting up a websocket application with ratchet websockets. My setup is the following: I (have to) use an nginx server as an reverse proxy forwarding requests to my websocket ratchet server:

    location /websocket {
        proxy_pass http://websocket;
        proxy_http_version 1.1;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_set_header X-NginX-Proxy true;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "Upgrade";
        proxy_redirect off;

Within my websocket app i need to get the value ($remote_addr) of X-Real-IP for IP filtering. Because i have to use this proxy solution i will always get the ip as the remote ip when using the function stream_socket_get_name.

As far as i have investigated this problem ratchet starts a stream_socket_server and then starts to listen for incomming connections. These connections are already streams and not http-requests so i'm not able to use something like $_SERVER etc.

Does anybody know how to retrieve this value?




Each ConnectionInterface object that is passed in the on methods contains a Guzzle RequestInterface object with the HTTP headers from the initial request:


Need Your Help

DropdownCheckList does not show all selected variables

javascript jquery html

I use this plugin for jQuery: but it does not show the default multiple selected variables

Twitter authentication fails

r twitter twitter-oauth

I would like to use the package twitteR for an analysis, but I came across a problem when I tried to authenticate with Twitter. Below are the error, and the code I use for the authentication. Anyon...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.