Skip to content

Instantly share code, notes, and snippets.

@codingmiao
Last active January 31, 2018 02:43
Show Gist options
  • Select an option

  • Save codingmiao/b5e4bf495af25efcbab7009e793e43f1 to your computer and use it in GitHub Desktop.

Select an option

Save codingmiao/b5e4bf495af25efcbab7009e793e43f1 to your computer and use it in GitHub Desktop.

Revisions

  1. codingmiao revised this gist Jan 31, 2018. 1 changed file with 4 additions and 1 deletion.
    5 changes: 4 additions & 1 deletion nginx常用命令和配置.md
    Original file line number Diff line number Diff line change
    @@ -12,4 +12,7 @@ quit表示正常退出nginx,并保存相关信息

    重启(因为改变了配置,需要重启)

    nginx -s reload
    nginx -s reload
    -------------------------
    引入一个配置
    include apps/test.conf;
  2. codingmiao created this gist Feb 4, 2017.
    15 changes: 15 additions & 0 deletions nginx常用命令和配置.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    启动

    直接点击Nginx目录下的nginx.exe 或者 cmd运行start nginx

    关闭

    nginx -s stop 或者 nginx -s quit

    stop表示立即停止nginx,不保存相关信息

    quit表示正常退出nginx,并保存相关信息

    重启(因为改变了配置,需要重启)

    nginx -s reload
    66 changes: 66 additions & 0 deletions 完整例子_nginx.conf
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,66 @@

    #user nobody;
    worker_processes 4;
    worker_cpu_affinity 0001 0010 0100 1000;

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

    #pid logs/nginx.pid;


    events {
    worker_connections 1024;
    }


    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 logs/access.log main;

    sendfile on;
    #tcp_nopush on;

    #keepalive_timeout 0;
    keepalive_timeout 65;

    gzip on;

    server {
    listen 7080;
    server_name localhost;
    proxy_buffer_size 128k;
    proxy_buffers 4 256k;
    proxy_busy_buffers_size 256k;
    default_type 'text/html';
    charset utf-8;

    location ^~ / {
    root html;
    index index.html index.htm;
    proxy_pass http://localhost:8080;
    proxy_set_header X-Real-IP $remote_addr;
    }

    location ^~ /jade2/ {
    root html;
    index index.html index.htm;
    proxy_pass http://10.181.0.128:8081;
    proxy_set_header X-Real-IP $remote_addr;
    expires 30d;
    }


    location ^~ /app/ {
    root "E:/_staticweb/";
    }

    }
    }
    16 changes: 16 additions & 0 deletions 映射到指定端口.conf
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    #映射jade2开头的url到指定web服务器(比如tomcat),url: http://localhost:7080/jade2/index.jsp
    location ^~ /jade2/ {
    root html;
    index index.html index.htm;
    proxy_pass http://10.181.0.128:8081;
    proxy_set_header X-Real-IP $remote_addr;
    expires 30d;#客户端缓存30天
    }

    #映射所有未配置的url到8080端口
    location ^~ / {
    root html;
    index index.html index.htm;
    proxy_pass http://localhost:8080;
    proxy_set_header X-Real-IP $remote_addr;
    }
    4 changes: 4 additions & 0 deletions 映射到文件目录.conf
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,4 @@
    #映射E:\_staticweb\app下的所有文件,例如当用户访问http://localhost:7080/app/wmstopo.html时,将访问E:\_staticweb\app\wmstopo.html
    location ^~ /app/ {
    root "E:/_staticweb/";
    }
    20 changes: 20 additions & 0 deletions 负载均衡.conf
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    #配置一组名为gs的集群
    upstream gs{
    least_conn;
    server 10.111.58.120:8282;
    server 10.111.58.122:8282;
    server 10.111.4.200:7001;
    }

    server {
    listen 7080;
    server_name localhost;
    proxy_buffer_size 128k;
    proxy_buffers 4 256k;
    proxy_busy_buffers_size 256k;
    #所有geoserver开头的请求转发到gs集群
    location ^~ /geoserver/ {
    proxy_pass http://gs;
    }

    }