Advertisement
patcito

nginx conf

Sep 16th, 2011
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.00 KB | None | 0 0
  1.  
  2. upstream foo_app_server {
  3. server unix:/var/run/foo/unicorn.sock fail_timeout=0;
  4. }
  5.  
  6. # foo Server
  7. server {
  8. listen 80;
  9. client_max_body_size 500M;
  10. server_name _ foo.com ec2-107-20-213-109.compute-1.amazonaws.com *.foo.com;
  11. gzip on;
  12. gzip_http_version 1.0;
  13. gzip_vary on;
  14. gzip_comp_level 6;
  15. gzip_proxied any;
  16. gzip_types text/plain text/html text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
  17. # make sure gzip does not lose large gzipped js or css files
  18. # see http://blog.leetsoft.com/2007/7/25/nginx-gzip-ssl
  19. gzip_buffers 16 8k;
  20.  
  21. # ~2 seconds is often enough for most folks to parse HTML/CSS and
  22. # retrieve needed images/icons/frames, connections are cheap in
  23. # nginx so increasing this is generally safe...
  24. keepalive_timeout 5;
  25.  
  26. # path for static files
  27. root /home/app/rails/foo/current/public;
  28. access_log /home/app/rails/foo/current/log/nginx.access.log;
  29. error_log /home/app/rails/foo/current/log/nginx.error.log;
  30.  
  31. # this rewrites all the requests to the maintenance.html
  32. # page if it exists in the doc root. This is for capistrano's
  33. # disable web task
  34. if (-f $document_root/system/maintenance.html) {
  35. rewrite ^(.*)$ /system/maintenance.html last;
  36. break;
  37. }
  38.  
  39. location / {
  40. try_files $uri $uri.html $uri/index.html @app;
  41. }
  42.  
  43. location @app {
  44. proxy_pass http://foo_app_server;
  45. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  46. proxy_set_header Host $http_host;
  47. }
  48.  
  49. location /images/ {
  50. # serve from disk and set expires
  51. expires max;
  52. }
  53.  
  54. location /stylesheets/ {
  55. expires max;
  56. }
  57.  
  58. location /javascripts/ {
  59. expires max;
  60. }
  61.  
  62. location /system/ {
  63. expires max;
  64. }
  65.  
  66. # Rails error pages
  67. error_page 500 502 503 504 /500.html;
  68. location = /500.html {
  69. root /home/app/rails/foo/current/public;
  70. }
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement