nginx-stream.conf.erb 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. worker_processes 1;
  2. daemon off;
  3. events {
  4. worker_connections 1024;
  5. }
  6. http {
  7. include /data/etc/nginx/mime.types;
  8. sendfile on;
  9. gzip on;
  10. gzip_http_version 1.1;
  11. gzip_proxied any;
  12. gzip_min_length 500;
  13. gzip_disable "MSIE [1-6]\.";
  14. gzip_types text/plain text/xml text/javascript text/css text/comma-separated-values application/xml+rss application/xml application/x-javascript application/json application/javascript application/atom+xml;
  15. # Proxy upstream to the node process
  16. upstream node {
  17. server 127.0.0.1:4000;
  18. }
  19. map $http_upgrade $connection_upgrade {
  20. default upgrade;
  21. '' close;
  22. }
  23. # Configuration for Nginx
  24. server {
  25. # Listen on port 8080
  26. listen 8080;
  27. add_header Strict-Transport-Security "max-age=31536000";
  28. add_header Content-Security-Policy "style-src 'self' 'unsafe-inline'; script-src 'self'; object-src 'self'; img-src data: https:; media-src data: https:; connect-src 'self' wss://<%= ENV["LOCAL_DOMAIN"] %>; upgrade-insecure-requests";
  29. root /app/public;
  30. location / {
  31. try_files $uri @node;
  32. }
  33. # Proxy connections to node
  34. location @node {
  35. proxy_set_header Host $host;
  36. proxy_pass http://node;
  37. proxy_buffering off;
  38. proxy_redirect off;
  39. proxy_http_version 1.1;
  40. proxy_set_header Upgrade $http_upgrade;
  41. proxy_set_header Connection $connection_upgrade;
  42. tcp_nodelay on;
  43. }
  44. }
  45. }