react.sh 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #!/bin/bash
  2. set -e
  3. if [ "$#" -ne 2 ]
  4. then
  5. echo "USAGE: $0 DOMAIN PORT"
  6. exit 1
  7. fi
  8. echo "check /etc/nginx/sites-enabled/$1.conf"
  9. if [ ! -f /etc/nginx/sites-enabled/$1.conf ]
  10. then
  11. cat > /etc/nginx/sites-enabled/$1.conf <<EOF
  12. server {
  13. server_name $1;
  14. access_log /var/log/nginx/$1.access.log;
  15. error_log /var/log/nginx/$1.error.log;
  16. gzip on;
  17. gzip_comp_level 9;
  18. gzip_min_length 1k;
  19. gzip_types text/plain text/css application/xml application/javascript;
  20. gzip_vary on;
  21. client_max_body_size 128M;
  22. location /my/ {
  23. alias /var/www/$1/current/dashboard/;
  24. try_files \$uri \$uri/ /my/index.html;
  25. location ~* \\.(css|js|png|jpg|jpeg|gif|gz|svg|mp4|ogg|ogv|webm|htc|xml|woff)\$ {
  26. access_log off;
  27. expires max;
  28. }
  29. }
  30. location / {
  31. proxy_set_header X-Forwarded-Proto http;
  32. proxy_set_header X-Real-IP \$remote_addr;
  33. proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
  34. proxy_set_header Host \$http_host;
  35. proxy_redirect off;
  36. proxy_pass http://127.0.0.1:$2;
  37. proxy_set_header Upgrade \$http_upgrade;
  38. proxy_set_header Connection "upgrade";
  39. }
  40. }
  41. EOF
  42. chmod 644 /etc/nginx/sites-enabled/$1.conf
  43. fi
  44. echo "done($1)."
  45. exit 0