Nginx 管理程序

Windows下 部署Nginx tomcat 设置个人记录
cls
@ECHO OFF
SET NGINX_PATH=D:
SET NGINX_DIR=D:\nginx\
color 0a
TITLE Nginx管理程序
GOTO MENU
:MENU
CLS
ECHO.
ECHO. * * * *  Nginx Management  * * * *
ECHO. * *
ECHO. * 1 启动Nginx *
ECHO. * *
ECHO. * 2 关闭Nginx *
ECHO. * *
ECHO. * 3 重启Nginx *
ECHO. * *
ECHO. * 4 退 出 *
ECHO. * *
ECHO. * * * * * * * * * * * * * * * * * * * * * * * *
ECHO.
ECHO.请输入选择项目的序号:
set /p ID=
IF "%id%"=="1" GOTO cmd1
IF "%id%"=="2" GOTO cmd2
IF "%id%"=="3" GOTO cmd3
IF "%id%"=="4" EXIT
PAUSE
:cmd1
ECHO.
ECHO.启动Nginx......
IF NOT EXIST %NGINX_DIR%nginx.exe ECHO %NGINX_DIR%nginx.exe不存在
%NGINX_PATH%
cd %NGINX_DIR%
IF EXIST %NGINX_DIR% start %NGINX_DIR%nginx.exe
ECHO.OK
PAUSE
GOTO MENU
:cmd2
ECHO.
ECHO.关闭Nginx......
taskkill /F /IM nginx.exe > nul
ECHO.OK
PAUSE
GOTO MENU
:cmd3
ECHO.
ECHO.关闭Nginx......
taskkill /F /IM nginx.exe > nul
ECHO.OK
GOTO cmd1
GOTO MENU
gzip.conf
gzip              on;
gzip_min_length   1024;
gzip_buffers      4 8k;
gzip_comp_level   9;
gzip_proxied      any;
gzip_types        application/xml application/javascript application/x-javascript application/atom+xml application/rss+xml;
gzip_types        text/css text/html text/javascript text/js text/plain text/xml;
proxy.conf
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
client_max_body_size 10m;
client_body_buffer_size 128k;
proxy_connect_timeout 300;
proxy_send_timeout 300;
proxy_read_timeout 300;
proxy_buffer_size 4k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
nginx.conf
#Nginx所用用户和组,window下不指定
#user  niumd niumd;
#工作的子进程数量(通常等于CPU数量或者2倍于CPU)
worker_processes  2;
#错误日志存放路径
#error_log  logs/error.log;
#error_log  logs/error.log  notice;
error_log  logs/error.log  info;
#指定pid存放文件
pid        logs/nginx.pid;
events {
#使用网络IO模型linux建议epoll,FreeBSD建议采用kqueue,window下不指定。
#use epoll;
#允许最大连接数
worker_connections  2048;
}
http {
include       mime.types;
default_type  application/octet-stream;
#定义日志格式
#log_format  main  '$remote_addr - $remote_user [$time_local] $request '
#                  '"$status" $body_bytes_sent "$http_referer" '
#                  '"$http_user_agent" "$http_x_forwarded_for"';
#access_log  off;
access_log  logs/access.log;
client_header_timeout  3m;
client_body_timeout    3m;
fastcgi_buffers 8 128k;
send_timeout           3m;
client_header_buffer_size    1k;
large_client_header_buffers  4 4k;
sendfile        on;
tcp_nopush      on;
tcp_nodelay     on;
#keepalive_timeout  75 20;
include    gzip.conf;
include    proxy.conf;
upstream localhost {
#根据ip计算将请求分配各那个后端tomcat,许多人误认为可以解决session问题,其实并不能。
#同一机器在多网情况下,路由切换,ip可能不同
#ip_hash;
#weigth参数表示权值,权值越高被分配到的几率越大
server 127.0.0.1:8080 weight=10;
}
server {
listen       80;
server_name  localhost;

    location / {
        root D:/tomcat1/webapps/ROOT/;
        index index.html index.htm index.jsp;
    }
    location ~ .*\.(html|js|css|png|gif|jpeg|jpg|apk|pda|swf|bmp)$ {
        root E:/W/workspace/1.0/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/com.cckj.smgr.server;
    }

    location ~ \.(jsp|action|do|m)$ {
        proxy_connect_timeout   3;
        proxy_send_timeout      30;
        proxy_read_timeout      30;
        proxy_pass http://localhost;
    }
    location ~ ^/(WEB-INF)/ {
        #这个很重要,不然用户就可以访问了
            deny all;
        }
}
}
 

你可能感兴趣的:(nginx,个人记录)