• Nginx配置WebService、MySQL、SQL Server、ORACLE等代理


    首先介绍一下Nginx的基本使用:

    注意不要直接双击nginx.exe,这样会导致修改配置后重启、停止nginx无效,需要手动关闭任务管理器内的所有nginx进程

    在nginx.exe目录,打开命令行工具,用命令 启动/关闭/重启nginx

    start nginx : 启动nginx
    nginx -s reload :修改配置后重新加载生效
    nginx -s reopen :重新打开日志文件
    nginx -t -c /path/to/nginx.conf 测试nginx配置文件是否正确

    关闭nginx:
    nginx -s stop :快速停止nginx
    nginx -s quit :完整有序的停止nginx


    如果遇到报错:
    bash: nginx: command not found

    有可能是你再linux命令行环境下运行了windows命令,

    如果你之前是允许 nginx -s reload报错, 试下 ./nginx -s reload

    或者 用windows系统自带命令行工具运行

    nginx配置webservice

    #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;
    
    
    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;
    
        upstream esbServer {   
            server 127.0.0.1:8083 weight=1 max_fails=2 fail_timeout=30s;   
        }
    
        #gzip  on;
    
        server {
            listen       8081;
            server_name  localhost;
    
            #charset koi8-r;
    
            #access_log  logs/host.access.log  main;
    
            location /ladder_web {
                proxy_set_header X-real-ip $remote_addr;
                proxy_pass http://esbServer;
            }
    
           
        }
    
    }
    

    nginx 配置mysql代理  -- 基于nginx1.9以上 stream module
     stream 模块用于一般的 TCP 代理和负载均衡。

    #user  nobody;
    worker_processes  1;
    
    #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;
    }
    
    stream {
        upstream sql {   
            server 172.16.10.229:3306 weight=1 max_fails=2 fail_timeout=30s;   
        }
        
         server {
            listen       3333;
            proxy_connect_timeout 1s;
            proxy_timeout 3s;
            proxy_pass sql;
        }
    }
    

    nginx配置Sql server服务代理

    #user  nobody;
    worker_processes  1;
    
    #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;
    }
    
    stream {
        
        upstream sqlserver {   
            server 172.16.10.167:1433 weight=1 max_fails=2 fail_timeout=30s;   
        }
        
    
         server {
            listen       3334;
            proxy_connect_timeout 1s;
            proxy_timeout 3s;
            proxy_pass sqlserver;
        }
    }
    

      nginx配置Oracle代理

    #user  nobody;
    worker_processes  1;
    
    #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;
    }
    
    stream {
        
        
        upstream oracle {   
            server 172.16.10.222:1521 weight=1 max_fails=2 fail_timeout=30s;   
        }
        
     server {
            listen       3335;
            proxy_connect_timeout 1s;
            proxy_timeout 3s;
            proxy_pass oracle;
        }
    }
    

      

     

  • 相关阅读:
    (九)排序——选择
    (八)排序——冒泡
    (七)排序算法
    (六)递归
    (五)栈
    (三)队列
    (二)稀疏数组
    Nessus号称是世界上最流行的漏洞扫描程序
    meterpreter ???
    IIS网站权限设置原则
  • 原文地址:https://www.cnblogs.com/airoot/p/10337870.html
Copyright © 2020-2023  润新知