Romain
Sep 19, 2013 9:10:09 AM

syncrify behind Nginx proxy does not return real IP address

Hello,

We've got a Syncrify server version 3.4 (b749) behind a nginx reverse proxy.

Everything works very well but the source client IP in the "remote clients" page returns the private IP of the reverse proxy itself instead of the real client public IP.

Here is the nginx config :

server {
listen 80;
server_name fqdn.example.com;

# Set global proxy settings
proxy_read_timeout 360;

proxy_pass_header Date;
proxy_pass_header Server;

set_real_ip_from 0.0.0.0/0;
real_ip_header X-Forwarded-For;

proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

location ~* ^/ { proxy_pass http://<Syncrify server IP):5800; }

error_log /var/log/nginx/backup-error.log;
access_log /var/log/nginx/backup-access.log;
}

Here is an example of the header in from of the syncrify server :

Host: fqdn.example.com
X-Real-IP: <Client public IP>
X-Forwarded-For: <Client public IP>
Connection: close
Cache-Control: max-age=0
Accept: image/webp,*/*;q=0.8
If-None-Match: W/"9637-1379352526000"
If-Modified-Since: Mon, 16 Sep 2013 17:28:46 GMT
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.66 Safari/537.36
Referer: http://fqdn.example.com/app
Accept-Encoding: gzip,deflate,sdch
Accept-Language: fr-FR,fr;q=0.8,en-US;q=0.6,en;q=0.4
Cookie: JSESSIONID=88DEDE24AA0AECBEC0E444028C8C2CFD

 

So we've got the right IP in the X-Real-IP and X-Forwarded-For headers but Syncrify doest not return the good one.

Does anyone have the same issue ? Is there any solution ?

Thanks in advance !



Rémi
Sep 19, 2013 10:39:07 AM

syncrify behind Nginx proxy does not return real IP address

Hi,

I have since a long time the same problem on Syncrify. Especially because if someone make a mistake on login, all session are blocked because the client IP correspond to the private proxy interface.

A the time, i have searched for a solution by modifying in the jsp file in manner to get the real IP in Syncrify without success.

To unlock the situation it will be great if Syncrify crew work on it.

So best way seems to integrate this code in the Syncrify sources to detect if the header X-forwarded-for exist or not :

  1. public static String getClientIpAddr(HttpServletRequest request) {  
  2.         String ip = request.getHeader("X-Forwarded-For");  
  3.         if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {  
  4.             ip = request.getHeader("Proxy-Client-IP");  
  5.         }  
  6.         if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {  
  7.             ip = request.getHeader("WL-Proxy-Client-IP");  
  8.         }  
  9.         if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {  
  10.             ip = request.getHeader("HTTP_CLIENT_IP");  
  11.         }  
  12.         if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {  
  13.             ip = request.getHeader("HTTP_X_FORWARDED_FOR");  
  14.         }  
  15.         if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {  
  16.             ip = request.getRemoteAddr();  
  17.         }  
  18.         return ip;  
  19.     } 


Dan
Dec 11, 2023 10:44:23 AM

syncrify behind Nginx proxy does not return real IP address

Hi,

We have the same problem is that something could get checked by the team please.

Thank you !



Synametrics support engineer
Dec 11, 2023 11:03:39 AM

syncrify behind Nginx proxy does not return real IP address

Dan,

The current version of Syncrify looks for X-Forwarded-For header. Do you know if your proxy server is adding this header into the requests? If yes, it should work.

 



Dan
Dec 11, 2023 11:10:28 AM

syncrify behind Nginx proxy does not return real IP address

Hi,

This is the headers pass by Nginx :

 

proxy_set_header X-Forwarded-Scheme
proxy_set_header X-Forwarded-Proto
proxy_set_header X-Forwarded-For 
proxy_set_header X-Real-IP 

Do you know at which version of Syncrify you added this ?

 

Thank you !



Synametrics support engineer
Dec 11, 2023 11:34:11 AM

syncrify behind Nginx proxy does not return real IP address

I think it was around version 5.6



Dan
Dec 11, 2023 1:28:00 PM

syncrify behind Nginx proxy does not return real IP address

That would explain, we are running Version: 5.4 - build 1117.

Thanks !

Navigation

Social Media

Powered by 10MinutesWeb.com