代理数据库

凛冬王昭君 2020年11月24日 275次浏览

10.17.145.181,10.17.145.182两台机器加入如下配置

80是it管理平台,3344是缺陷数据库,3345是云流程平台,3346是综合办公

生产缺陷代理

配置nginx配置文件nginx.conf,加入stream,如下

stream {
    upstream sqlserver {
        server 10.20.148.13:1433 weight=1 max_fails=2 fail_timeout=30s;
    }
    server {
          listen       3344;
          proxy_connect_timeout 1s;
          proxy_timeout 3s;
          proxy_pass sqlserver;
       }
}

注意:stream模块在http模块之外

WX20201124114501.png

生产(it管理平台,云流程,oa系统)代理

配置nginx配置文件nginx.conf,加入修改如下配置

 http {
    include       /etc/nginx/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  /var/log/nginx/access.log  main;
    sendfile        on;
    #tcp_nopush     on;
    keepalive_timeout  65;
    #gzip  on;
    server {
    	listen       80;
    	server_name  localhost;
    	add_header Content-Security-Policy upgrade-insecure-requests;
    	location / {
        	add_header Content-Security-Policy upgrade-insecure-requests;
        	proxy_set_header HOST $host;
        	proxy_set_header X-Forwarded-Proto $scheme;
        	proxy_set_header X-Real-IP $remote_addr;
        	proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        	proxy_pass http://10.21.34.49:8044/;
    	}
    }

    server {
    	listen       3345;
    	server_name  localhost;
    	add_header Content-Security-Policy upgrade-insecure-requests;
    	location / {
        	add_header Content-Security-Policy upgrade-insecure-requests;
        	proxy_set_header HOST $host;
        	proxy_set_header X-Forwarded-Proto $scheme;
        	proxy_set_header X-Real-IP $remote_addr;
        	proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        	proxy_pass http://10.21.38.30:80/;
    	}

        location /efc-automation-prod/ {
        	add_header Content-Security-Policy upgrade-insecure-requests;
        	proxy_set_header HOST $host;
        	proxy_set_header X-Forwarded-Proto $scheme;
        	proxy_set_header X-Real-IP $remote_addr;
        	proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        	proxy_pass http://10.18.20.106:3345;
    	}
    }

    server {
    	listen       3346;
    	server_name  localhost;
    	add_header Content-Security-Policy upgrade-insecure-requests;
    	location / {
        	add_header Content-Security-Policy upgrade-insecure-requests;
        	proxy_set_header HOST $host;
        	proxy_set_header X-Forwarded-Proto $scheme;
        	proxy_set_header X-Real-IP $remote_addr;
        	proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        	proxy_pass http://10.21.3.25:8000/;
    	}
   }
}