Advertisement
Guest User

Untitled

a guest
Apr 2nd, 2015
260
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Nginx 3.04 KB | None | 0 0
  1.     http {
  2.         include       mime.types;
  3.         default_type  application/octet-stream;
  4.    
  5.         #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
  6.         #                  '$status $body_bytes_sent "$http_referer" '
  7.         #                  '"$http_user_agent" "$http_x_forwarded_for"';
  8.    
  9.         #access_log  logs/access.log  main;
  10.    
  11.         sendfile        on;
  12.         #tcp_nopush     on;
  13.    
  14.         #keepalive_timeout  0;
  15.         keepalive_timeout  65;
  16.    
  17.         #gzip  on;
  18.    
  19.         fastcgi_buffers 256 4k;
  20.    
  21.         # define an easy to reference name that can be used in fastgi_pass
  22.         upstream heroku-fcgi {
  23.             #server 127.0.0.1:4999 max_fails=3 fail_timeout=3s;
  24.             server unix:/tmp/heroku.fcgi.8080.sock max_fails=3 fail_timeout=3s;
  25.             keepalive 16;
  26.         }
  27.        
  28.         server {
  29.             # define an easy to reference name that can be used in try_files
  30.             location @heroku-fcgi {
  31.                 include fastcgi_params;
  32.                
  33.                 fastcgi_split_path_info ^(.+\.php)(/.*)$;
  34.                 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  35.                 # try_files resets $fastcgi_path_info, see http://trac.nginx.org/nginx/ticket/321, so we use the if instead
  36.                 fastcgi_param PATH_INFO $fastcgi_path_info if_not_empty;
  37.                
  38.                 if (!-f $document_root$fastcgi_script_name) {
  39.                     # check if the script exists
  40.                     # otherwise, /foo.jpg/bar.php would get passed to FPM, which wouldn't run it as it's not in the list of allowed extensions, but this check is a good idea anyway, just in case
  41.                     return 404;
  42.                 }
  43.                
  44.                 fastcgi_pass heroku-fcgi;
  45.             }
  46.            
  47.             # TODO: use X-Forwarded-Host? http://comments.gmane.org/gmane.comp.web.nginx.english/2170
  48.             server_name localhost;
  49.             listen 8080;
  50.             # FIXME: breaks redirects with foreman
  51.             port_in_redirect off;
  52.            
  53.             root "/app";
  54.            
  55.             error_log stderr;
  56.             access_log /tmp/heroku.nginx_access.8080.log;
  57.            
  58.             location ~* \.(?:js)$ {
  59.               expires 1y;
  60.               access_log off;
  61.               add_header Cache-Control "public";
  62.             }
  63.            
  64.             location / {
  65.                 # try to serve file directly, fallback to rewrite
  66.                 try_files $uri @rewriteapp;
  67.             }
  68.            
  69.             location @rewriteapp {
  70.                 # rewrite all to app.php
  71.                 rewrite ^(.*)$ /index.php$1 last;
  72.             }            
  73.            
  74.             # restrict access to hidden files, just in case
  75.             location ~ /\. {
  76.                 deny all;
  77.             }
  78.            
  79.             # default handling of .php
  80.             location ~ \.php {
  81.                 try_files @heroku-fcgi @heroku-fcgi;
  82.             }
  83.         }
  84.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement