@SKRSKR

Real ip nginx + apache не работает?

В HTTP_X_REAL_IP и HTTP_X_FORWARDED_FOR нормальный айпи, а в REMOTE_ADDR 127.0.0.1. Мне нужен именно REMOTE_ADDR
Конфиг nginx:
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>

Пытался ставил rpaf, realip но ничего не работает. Помогите пожалуйста, уже наверное весь инет облазил на всех языках
  • Вопрос задан
  • 1068 просмотров
Решения вопроса 1
@SKRSKR Автор вопроса
Пофиксил сам:
Указал в apache default conf

RemoteIPHeader X-Forwarded-For
RemoteIPInternalProxy 127.0.0.1

и подключил remoteip_module
Ответ написан
Комментировать
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы