S
S
SKRSKR2016-10-16 23:37:54
linux
SKRSKR, 2016-10-16 23:37:54

Real ip nginx + apache not working?

In HTTP_X_REAL_IP and HTTP_X_FORWARDED_FOR normal ip, and in REMOTE_ADDR 127.0.0.1. I need exactly REMOTE_ADDR
nginx config:

listen *:80; ## listen for ipv4
server_name ***;
access_log /var/log/nginx/access.log;
# Перенаправление на back-end
location / {
proxy_pass http://127.0.0.1:228;
            proxy_set_header X-Real-IP  $remote_addr;
            proxy_set_header X-Forwarded-For $remote_addr;
           
            proxy_set_header Host $host;
            gzip on;
    gzip_disable "msie6";
    gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript;
    }
# Статическиое наполнение отдает сам nginx
# back-end этим заниматься не должен
location ~* \.(jpg|jpeg|gif|png|ico|css|bmp|swf|js|html|txt|woff2|eot)$ {
root /var/www/;
expires 3d;

apache:
<VirtualHost 127.0.0.1:228>
  # The ServerName directive sets the request scheme, hostname and port that
  # the server uses to identify itself. This is used when creating
  # redirection URLs. In the context of virtual hosts, the ServerName
  # specifies what hostname must appear in the request's Host: header to
  # match this virtual host. For the default virtual host (this file) this
  # value is not decisive as it is used as a last resort host regardless.
  # However, you must set it for any further virtual host explicitly.
  ServerName ***
    
  DocumentRoot /var/www/
  # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
  # error, crit, alert, emerg.
  # It is also possible to configure the loglevel for particular
  # modules, e.g.
  #LogLevel info ssl:warn
    CustomLog ${APACHE_LOG_DIR}/access.log combined
  ErrorLog ${APACHE_LOG_DIR}/error.log
  CustomLog ${APACHE_LOG_DIR}/access.log combined
  # For most configuration files from conf-available/, which are
  # enabled or disabled at a global level, it is possible to
  # include a line for only one particular virtual host. For example the
  # following line enables the CGI configuration for this host only
  # after it has been globally disabled with "a2disconf".
  #Include conf-available/serve-cgi-bin.conf
    # The following lines allow client IP to be passed from Nginx to Apache
</VirtualHost>

Tried to put rpaf, realip but nothing works. Help please, probably the whole Internet has already climbed in all languages

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
SKRSKR, 2016-10-17
@SKRSKR

Fixed it myself: Specified
in apache default conf
RemoteIPHeader X-Forwarded-For
RemoteIPInternalProxy 127.0.0.1
and connected remoteip_module

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question