美文网首页
Nginx的使用

Nginx的使用

作者: DesertSnow | 来源:发表于2017-05-19 11:32 被阅读0次
1,修改nginx.conf
#user  nobody;
worker_processes  4;

error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

pid        logs/nginx.pid;

worker_rlimit_nofile 65535;

events {
    worker_connections  65535;
    multi_accept on;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] $host "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  logs/access.log  main;

    server_tokens   off;
    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;
    
    upstream count_boss {
      server 192.168.8.236:3480;
    }

    server {
        listen       9191;
        server_name  192.168.8.47;

        #charset koi8-r;

        access_log logs/host.access.log;

        location / {
            root   html;
            index  index.html index.htm;
        }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
        
        # count_boss
        location /boss/ {
            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;
            proxy_set_header X-Scheme $scheme;
            proxy_set_header Cookie $http_cookie;
            client_max_body_size 50m;
            client_body_buffer_size 256k;
            proxy_connect_timeout 75;
            proxy_send_timeout 120;
            proxy_read_timeout 300;
            proxy_buffer_size 256k;
            proxy_buffers 4 256k;
            proxy_busy_buffers_size 256k;
            proxy_temp_file_write_size 256k;
            # proxy_next_upstream error timeout invalid_header http_500 http_503 http_404;
            proxy_max_temp_file_size 128m;
            proxy_pass  http://count_boss/boss/;    #请求转向定义的服务器列表
        }
        

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        #location ~ \.php$ {
        #    root           html;
        #    fastcgi_pass   127.0.0.1:9000;
        #    fastcgi_index  index.php;
        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        #    include        fastcgi_params;
        #}

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }


    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    #    listen       8000;
    #    listen       somename:8080;
    #    server_name  somename  alias  another.alias;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}


    # HTTPS server
    #
    #server {
    #    listen       443 ssl;
    #    server_name  localhost;

    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;

    #    ssl_session_cache    shared:SSL:1m;
    #    ssl_session_timeout  5m;

    #    ssl_ciphers  HIGH:!aNULL:!MD5;
    #    ssl_prefer_server_ciphers  on;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}

}

2,nginx命令
## 关闭nginx
nginx -s stop


## 关闭nginx
taskkill /F /IM nginx.exe > null 


## 查看nginx
tasklist /fi "imagename eq nginx.exe"

## 测试nginx.conf正确性
nginx.exe –t


## start.bat
C:
cd C:\Users\lixj\Desktop\nginx-1.12.0
start nginx 


## stop.bat
C:
cd C:\Users\lixj\Desktop\nginx-1.12.0
taskkill /F /IM nginx.exe>nul


## reload.bat
C:
cd C:\Users\lixj\Desktop\nginx-1.12.0
nginx -s reload




## 分享下bat文件

====================================================
@echo off
rem 当前bat的作用

echo ==================begin========================

cls 
SET NGINX_PATH=C:
SET NGINX_DIR=C:\Users\lixj\Desktop\nginx-1.12.0\
color 0a 
TITLE Nginx 管理程序控制面板

CLS 

ECHO. 
ECHO. * Nginx Manage System *
ECHO. * Author lixj * 
ECHO. * Date 2017-05-19 * 
ECHO. 

:MENU 

ECHO. * nginx process list * 
tasklist|findstr /i "nginx.exe"

ECHO. 
ECHO. [1] 启动Nginx 
ECHO. [2] 关闭Nginx 
ECHO. [3] 重启Nginx 
ECHO. [4] 退 出 
ECHO. 

ECHO.请输入选择项目的序号:
set /p ID=
IF "%id%"=="1" GOTO start 
IF "%id%"=="2" GOTO stop 
IF "%id%"=="3" GOTO restart 
IF "%id%"=="4" EXIT
PAUSE 

:start 
call :startNginx
GOTO MENU

:stop 
call :shutdownNginx
GOTO MENU

:restart 
call :shutdownNginx
call :startNginx
GOTO MENU

:shutdownNginx
ECHO. 
ECHO.关闭Nginx...... 
taskkill /F /IM nginx.exe > nul
ECHO.OK,关闭所有nginx 进程
goto :eof

:startNginx
ECHO. 
ECHO.启动Nginx...... 
IF NOT EXIST "%NGINX_DIR%nginx.exe" ECHO "%NGINX_DIR%nginx.exe"不存在 

%NGINX_PATH% 

cd "%NGINX_DIR%" 

IF EXIST "%NGINX_DIR%nginx.exe" (
echo "start '' nginx.exe"
start "" nginx.exe
)
ECHO.OK
goto :eof

相关文章

  • 贵安项目nginx配置

    关于nginx的使用以及为什么使用【Nginx】什么是Nginx?为什么使用Nginx?nginx 之 proxy...

  • brew下安装并且使用nginx

    使用 brew search nginx命令,搜索nginx 使用 brew install nginx命令,安...

  • mac 配置Nginx服务

    安装nginx brew install nginx安装后使用nginx -v查看nginx版本 配置nginx ...

  • Docker Nginx的使用

    Docker Nginx的使用 使用dockerfile定制nginx镜像新建一个目录t-nginx sudo m...

  • nginx与uWsgi

    什么是nginx 为什么使用nginx nginx、WSGI、uwsgi、uWSGI nginx和uWSGI 的意...

  • Nginx作为代理服务

    一. 为什么使用Nginx 要回答为什么要使用nginx,那就先说说nginx能做些什么。首先,nginx能做反向...

  • nginx: [emerg] bind() to 0.0.0.0

    使用systemctl start nginx启动nginx失败, 使用systemctl status ngin...

  • Nginx的高级使用

    1、概述 之前介绍过Nginx的简单使用,今天来聊聊Nginx的一些高级使用。 2、使用Nginx解决跨域问题 当...

  • Tomcat

    方案二: Nginx+Tomcat方案三: 使用nginx做反向代理负载均衡 建议使用Nginx和Tomca...

  • 【Docker 系列】docker 学习 三

    【Docker 系列】docker 学习 三 使用 Dcoker 部署 nginx 搜索 nginx 镜像 使用 ...

网友评论

      本文标题:Nginx的使用

      本文链接:https://www.haomeiwen.com/subject/fyhyxxtx.html