gplessis / dotdeb-nginx

Dotdeb : Nginx
http://www.dotdeb.org/
BSD 2-Clause "Simplified" License
63 stars 31 forks source link

[Feature Request] Nginx Real-IP #61

Closed Padrio closed 9 years ago

Padrio commented 9 years ago

Is there any chance to get the real-ip module implemented? It's very usefull if you're using a reverse proxy like cloudflare.

gplessis commented 9 years ago

Already included in all nginx flavors.

Padrio commented 9 years ago

So why im getting this error? 2015/04/22 15:29:07 [emerg] 11413#0: unknown directive "set_real_ip_from  " in /etc/nginx/sites-enabled/default:6

gplessis commented 9 years ago

It's strange, because it's enabled in the default config : https://github.com/gplessis/dotdeb-nginx/blob/wheezy/debian/rules

Could you please paste the result of dpkg -l 'nginx*'?

Padrio commented 9 years ago

http://puu.sh/hol7c/6a24044990.png

gplessis commented 9 years ago

I have the exact same config/version with nginx-full :

http {
...
        set_real_ip_from 10.0.0.0/8;
        real_ip_header X-Forwarded-For;
...
}

And it works. Could you please check that you don't have a typo in your config files?

Padrio commented 9 years ago

I've put this into the server config.

server {
    (...)
        set_real_ip_from   204.93.240.0/24;
        set_real_ip_from   204.93.177.0/24;
        set_real_ip_from   199.27.128.0/21;
        set_real_ip_from   173.245.48.0/20;
        set_real_ip_from   103.21.244.0/22;
        set_real_ip_from   103.22.200.0/22;
        set_real_ip_from   103.31.4.0/22;
        set_real_ip_from   141.101.64.0/18;
        set_real_ip_from   108.162.192.0/18;
        set_real_ip_from   190.93.240.0/20;
        set_real_ip_from   188.114.96.0/20; 
        set_real_ip_from   197.234.240.0/22;
        set_real_ip_from   198.41.128.0/17;
        set_real_ip_from   2400:cb00::/32;
        set_real_ip_from   2606:4700::/32;
        set_real_ip_from   2803:f800::/32;
        set_real_ip_from   2405:b500::/32;
        set_real_ip_from   2405:8100::/32;
        real_ip_header     CF-Connecting-IP;
    (...)
}

The error-log says it's in line 6, in this case its the first "set_real_ip_from" directive. Edit: Same in the http { } configuration

Padrio commented 9 years ago

Okay! IT WAS A F*\ WHITESPACE! Thanks nginx :-1: