title: Nginx cloudflare 502 bad gateway
body: <p>I'm using cloudflare. My site is working good but not loading any images, css files and js files.</p>
  <p><img src="https://i.stack.imgur.com/9WfHz.png" alt="look that" /></p>
  <p>My server details;</p>
  <blockquote>
  <p>ubuntu 12.04</p>
  <p>nginx/1.1.19</p>
  <p>php5-fpm</p>
  <p>mysql</p>
  </blockquote>
  <p>You can check live <a href="http://www.sorbakalim.co" rel="nofollow noreferrer">here</a></p>
  <p>Check with www and without www.</p>
  <p>I think that problem is related to proxy (cloudflare)</p>
  <blockquote>
  <p>/etc/nginx.conf</p>
  </blockquote>
  <pre><code>user www-data;                                                                  
  worker_processes 4;                                                             
  pid /var/run/nginx.pid;                                                         
                                                                                  
  events {                                                                        
      worker_connections 768;                                                     
      # multi_accept on;                                                          
  }                                                                               
                                                                                  
  http {                                                                          
                                                                                  
      ##                                                                          
      # Basic Settings                                                            
      ##                                                                          
                                                                                  
      sendfile on;                                                                
      tcp_nopush on;                                                              
      tcp_nodelay on;                                                             
      keepalive_timeout 65;                                                       
      types_hash_max_size 2048;                                                   
      # server_tokens off;                                                        
                                                                                  
      # server_names_hash_bucket_size 64;                                         
      # server_name_in_redirect off;                                              
                                                                                  
      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;                                         
                                                                                  
      ##                                                                          
      # Gzip Settings                                                             
      ##                                                                          
                                                                                  
      gzip on;                                                                    
      gzip_disable &quot;msie6&quot;;                                                       
                                                                                  
      # gzip_vary on;                                                             
      # gzip_proxied any;                                                         
      # gzip_comp_level 6;                                                        
      # gzip_buffers 16 8k;                                                       
      # gzip_http_version 1.1;                                                    
      # gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
                                                                                  
      ##                                                                          
      # nginx-naxsi config                                                        
      ##                                                                          
      # Uncomment it if you installed nginx-naxsi                                 
      ##                                                                          
                                                                                  
      #include /etc/nginx/naxsi_core.rules;                                       
                                                                                  
      ##                                                                          
      # nginx-passenger config                                                    
      ##                                                                          
      # Uncomment it if you installed nginx-passenger                             
      ##                                                                          
                                                                                  
      #passenger_root /usr;                                                       
      #passenger_ruby /usr/bin/ruby;                                              
                                                                                  
      ##                                                                          
      # Virtual Host Configs                                                      
      ##                                                                          
                                                                                  
      include /etc/nginx/conf.d/*.conf;                                           
      include /etc/nginx/sites-enabled/*;                                         
  }   
  </code></pre>
  <p>server conf</p>
  <pre><code>server {                                                                        
      #listen   80; ## listen for ipv4; this line is default and implied          
      #listen   [::]:80 default ipv6only=on; ## listen for ipv6                   
                                                                                  
      root /usr/share/nginx/www/sorbakalim.co;                                    
      index index.html index.htm index.php;                                       
                                                                                  
      # Make site accessible from http://localhost/                               
      server_name sorbakalim.co;                                                  
                                                                                  
      location / {                                                                
          # First attempt to serve request as file, then                          
          # as directory, then fall back to index.html                            
          try_files $uri $uri/ /index.php;                                        
          # Uncomment to enable naxsi on this location                            
          # include /etc/nginx/naxsi.rules                                        
      }                                                                           
                                                                                  
      location /doc/ {                                                            
          alias /usr/share/doc/;                                                  
          autoindex on;                                                           
          allow 127.0.0.1;                                                        
          deny all;                                                               
      }                                                                           
                                                                                  
      # Only for nginx-naxsi : process denied requests                            
      #location /RequestDenied {                                                  
          # For example, return an error code                                     
          #return 418;                                                            
      #}                                                                          
                                                                                  
      #error_page 404 /404.html;                                                  
                                                                                  
      # redirect server error pages to the static page /50x.html                  
      #                                                                           
      #error_page 500 502 503 504 /50x.html;                                      
      #location = /50x.html {                                                     
      #   root /usr/share/nginx/www;                                              
      #}                                                                          
                                                                                  
      # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000        
      #                                                                           
      location ~ \.php$ {                                                         
          fastcgi_split_path_info ^(.+\.php)(/.+)$;                               
          # NOTE: You should have &quot;cgi.fix_pathinfo = 0;&quot; in php.ini              
                                                                                  
          # With php5-cgi alone:                                                  
          fastcgi_pass 127.0.0.1:9000;                                            
      #   # With php5-fpm:                                                        
      #   fastcgi_pass unix:/var/run/php5-fpm.sock;                               
          fastcgi_index index.php;                                                
          include fastcgi_params;                                                 
      }                                                                           
                                                                                  
      # deny access to .htaccess files, if Apache's document root                 
      # concurs with nginx's one                                                  
      #                                                                           
      #location ~ /\.ht {                                                         
      #   deny all;                                                               
      #}                                                                          
  }
  </code></pre>