Jelajahi Sumber

add nginx start shell, proxy configuration

ZhenQin 11 tahun lalu
induk
melakukan
40706f0d36
2 mengubah file dengan 74 tambahan dan 0 penghapusan
  1. 52 0
      nginx/nginx
  2. 22 0
      nginx/proxy.conf

+ 52 - 0
nginx/nginx

@@ -0,0 +1,52 @@
+#!/usr/bin/env bash
+#description: Startup and shutdown script for nginx
+#define nginx diri
+
+CURRENT_DIR=$(cd "$(dirname "$0")"; pwd)
+
+NGINX_INSTALL="/usr/local/nginx"
+NGINX="$NGINX_INSTALL/sbin/nginx"
+NGINX_CONFIG="$NGINX_INSTALL/conf/nginx.conf"
+NGINX_PID="$NGINX_INSTALL/nginx.pid"
+
+case $1 in
+    'start' )
+        if test -x $NGINX
+        then
+            echo "Starting Nginx.. config: $NGINX_CONFIG"
+            if $NGINX -c $NGINX_CONFIG
+            then
+                echo "OK"
+            else
+                echo "failed"
+            fi
+        else
+            echo "Couldn't find Nginx($NGINX)"
+        fi
+        ;;
+
+    'stop' )
+        echo "Stopping Nginx..."
+        if $NGINX -s stop
+        then
+            echo "OK"
+        else
+            echo "failed"
+        fi
+        ;;
+
+    'restart'|'reload' )
+        if $NGINX -s reload
+        then
+            echo "OK"
+        else
+            echo "failed"
+        fi
+        ;;
+
+    'list' )
+        ps aux | egrep '(PID|nginx)'
+        ;;
+    *)
+echo "usage: `basename $0` {start|restart|reload|stop|list}"
+esac

+ 22 - 0
nginx/proxy.conf

@@ -0,0 +1,22 @@
+proxy_redirect          off;
+proxy_set_header        Host            $host;
+proxy_set_header        X-Real-IP       $remote_addr;
+proxy_set_header        User-Agent      $http_user_agent;
+proxy_set_header        Referer         $http_referer;
+proxy_set_header        Cookie          $http_cookie;
+proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
+
+#客户端上传文件的最大大小
+client_max_body_size    10m;
+client_body_buffer_size 128k;
+
+#浏览器等待的最长超时时间
+proxy_connect_timeout   30s;
+#后端服务器发送的超时时间
+proxy_send_timeout      20s;
+#后端服务器的读取超时时间
+proxy_read_timeout      20s;
+#缓冲区大小
+proxy_buffer_size       256k;
+#缓冲区个数
+proxy_buffers       4   256k;