Advertisement
Guest User

my_nginx_server_block

a guest
Apr 29th, 2013
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. # I need to make a few rewrite rules based on subdomain and domain, for instance
  2. # mydomain.de should "transparently" provide my_app/de$1
  3. #
  4. #
  5. # example:
  6. # mydomain.de/json/my-file.json ~> mydomain.com/de/json/my-file.json
  7. # (www\.)?mydomain\.(it|jp|es|de) ~> http://app_server/$2
  8.  
  9. upstream app_server {
  10. # for UNIX domain socket setups:
  11. server unix:/tmp/.sock fail_timeout=0;
  12.  
  13. # for TCP setups, point these to your backend servers
  14. # server 127.0.0.1:8080 fail_timeout=0;
  15. # server 192.168.0.8:8080 fail_timeout=0;
  16. # server 192.168.0.9:8080 fail_timeout=0;
  17. }
  18.  
  19. server {
  20. listen 80 default deferred;
  21.  
  22. client_max_body_size 4G;
  23. server_name _;
  24.  
  25. keepalive_timeout 5;
  26.  
  27. # path for static files
  28. root /home/app_user/current/my_app/public/;
  29.  
  30. # Prefer to serve static files directly from nginx to avoid unnecessary
  31. try_files $uri/index.html $uri.html $uri @app;
  32.  
  33. location @app {
  34. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  35.  
  36. proxy_set_header Host $http_host;
  37.  
  38. proxy_redirect off;
  39.  
  40. proxy_pass http://app_server;
  41. }
  42.  
  43. # Rails error pages
  44. error_page 500 502 503 504 /500.html;
  45. location = /500.html {
  46. root /path/to/app/current/public;
  47. }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement