Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I've been attempting to use HttpRealipModule with the CloudFlare IP range in my main nginx configuration file but upon restarting nginx I'll just get a standard `"configuration file /etc/nginx/nginx.conf test failed" and my site will go down.

This is what I've been attempting to do with my nginx.conf;

    user www-data;
worker_processes 1;

error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;


events {
    worker_connections  1024;
}

http {

    # Basic Settings
  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.22.200.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   2400:cb00::/32;
  set_real_ip_from   2606:4700::/32;
  set_real_ip_from   2803:f800::/32;
  real_ip_header     CF-Connecting-IP;
    client_max_body_size 50m;
    client_header_timeout 5;
    keepalive_timeout 5;
    port_in_redirect off;
    sendfile on;
    server_tokens off;
    server_name_in_redirect off;
    tcp_nopush on;
    tcp_nodelay on;
    types_hash_max_size 2048;

    # MIME
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    # Logging Settings
    access_log  /var/log/nginx/access.log;
    error_log  /var/log/nginx/error.log warn;

    # Gzip Settings
    gzip on;
    gzip_disable    "msie6";
    gzip_min_length 1400;
    gzip_types      text/plain text/css text/javascript text/xml application/x-javascript application/xml application/xml+rss;

    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;
}

What's wrong with that configuration file?

share|improve this question
    
please post full error message. The config you pasted doesn't give any error in my test. Output of nginx -V would also help. –  edogawaconan Oct 26 '12 at 17:29
add comment

1 Answer

Try to integrate this way:

    # Cloudflare
    real_ip_header X-Forwarded-For;

   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_recursive on;
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.