Почему socket получает ip сервера, а не клиента

Тема в разделе "Настройка веб-сервера", создана пользователем Stivins, 28 июн 2019.

  1. Stivins

    Stivins Активный пользователь

    С нами с:
    3 окт 2014
    Сообщения:
    6
    Симпатии:
    0
    Плохо разбираюсь в конфигах ngnix, но после того как перевел сервер на SSL, сокет стал получать IP самого сервака, а не клиента:

    NGNIX CONF:
    Код:
    server {
        server_name site.ru www.site.ru;
        return 301 https://$host:443$request_uri;
        charset UTF-8;
        index index.php index.html;
        disable_symlinks if_not_owner from=$root_path;
        include /etc/nginx/vhosts-includes/*.conf;
        include /etc/nginx/vhosts-resources/site.ru/*.conf;
        access_log /var/www/httpd-logs/site.ru.access.log;
        error_log /var/www/httpd-logs/site.ru.error.log notice;
        ssi on;
        set $root_path /var/www/user/data/www/site.ru;
        root $root_path;
        listen 176.99.12.56:80;
        location / {
            location ~ [^/]\.ph(p\d*|tml)$ {
                try_files /does_not_exists @fallback;
            }
            location ~* ^.+\.(jpg|jpeg|gif|png|svg|js|css|mp3|ogg|mpe?g|avi|zip|gz|bz2?|rar|swf)$ {
                try_files $uri $uri/ @fallback;
            }
            location / {
                try_files /does_not_exists @fallback;
            }
        }
        location @fallback {
            proxy_pass http://127.0.0.1:8080;
            proxy_redirect http://127.0.0.1:8080 /;
            proxy_set_header Host $host;
            proxy_set_header X-Forwarded-For $remote_addr;
            proxy_set_header X-Forwarded-Proto $scheme;
            proxy_set_header X-Forwarded-Port $server_port;
            access_log off;
        }
    }
    
    server
    {
    listen 443 ssl;
    ssl_certificate /etc/ssl/site.ru.crt;
    ssl_certificate_key /etc/ssl/site.ru.key;
    server_name epiclang.online www.site.ru;
    charset UTF-8;
    index index.php index.html;
    disable_symlinks if_not_owner from=$root_path;
    include /etc/nginx/vhosts-includes/*.conf;
    include /etc/nginx/vhosts-resources/site.ru/*.conf;
    access_log /var/www/httpd-logs/site.ru.access.log;
    error_log /var/www/httpd-logs/site.ru.error.log notice;
    ssi on;
    set $root_path /var/www/user/data/www/site.ru;
    root $root_path;
    location / {
      location ~ [^/]\.ph(p\d*|tml)$ {
       try_files /does_not_exists @fallback;
      }
      location ~* ^.+\.(jpg|jpeg|gif|png|svg|js|css|mp3|ogg|mpe?g|avi|zip|gz|bz2?|rar|swf)$ {
       try_files $uri $uri/ @fallback;
      }
      location / {
       try_files /does_not_exists @fallback;
     
      }
    
    }
    location @fallback {
      proxy_pass http://127.0.0.1:8080;
      proxy_redirect http://127.0.0.1:8080 /;
      proxy_set_header Host $host;
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header X-Forwarded-Proto $scheme;
      proxy_set_header X-Forwarded-Port $server_port;
      access_log off;
    }
    
    
    location /ws/ {
                    proxy_pass http://site.ru:8000/components/socket.php;
                    proxy_http_version 1.1;
                    proxy_set_header Upgrade $http_upgrade;
                    proxy_set_header Connection "upgrade";
                    proxy_set_header Host $host;
                    proxy_set_header X-Real-IP $remote_addr;
                    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                    proxy_set_header X-Forwarded-Proto https;
                    proxy_read_timeout 999999999; # neccessary to avoid websocket timeout disconnect
                    proxy_redirect off;
    
        }
    
    
    }
    IP получаю:
    Код:
    socket_getpeername($socket_new, $ip);