Nginx配置WebServiceMySQLSQL ServerORACLE等代理

Posted 斌灬小生不才

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Nginx配置WebServiceMySQLSQL ServerORACLE等代理相关的知识,希望对你有一定的参考价值。

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;
    }
}

 

以上是关于Nginx配置WebServiceMySQLSQL ServerORACLE等代理的主要内容,如果未能解决你的问题,请参考以下文章

nginx 更改配置文件后 需要重启吗

nginx 如何检测配置文件的正确性

nginx配置

nginx启动与配置

如何用nginx.conf配置nginx

nginx如何配置代理