nginx 正向代理 配置

启动, 重启

nginx -c /etc/nginx/nginx.conf

nginx -c /etc/nginx/nginx.conf -s reload

 

 

stream{
upstream backend{
server w-2wwmuxxxd.com:5432;
}
server{
listen 5432;
#allow 116.62.111.17; #jobAgent1
allow 192.168.0.0/2; #jd agent
deny all;
proxy_connect_timeout 10s; #后端服务器连接的超时时间_发起握手等候响应超时时间
#proxy_read_timeout 180s; #连接成功后_等候后端服务器响应时间_其实已经进入后端的排队之中等候处理(也可以说是后端服务器处理请求的时间)
#proxy_send_timeout 180s; #后端服务器数据回传时间_就是在规定时间之内后端服务器必须传完所有的数据
proxy_timeout 1800s; #代理超时
proxy_pass backend;
}
}

 

 

# For more information on configuration, see:
#   * Official English Documentation: http://nginx.org/en/docs/
#   * Official Russian Documentation: http://nginx.org/ru/docs/

user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;

# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;

events {
    worker_connections 1024;
}

stream{
		upstream backend{
			server rdsfzfvvrv.mysql.rds.aliyuncs.com:3306;
		}

		log_format main '$remote_addr [$time_local] '
		                 '$protocol $status $bytes_sent $bytes_received '
		                 '$session_time "$upstream_addr" '
		                 '"$upstream_bytes_sent" "$upstream_bytes_received" "$upstream_connect_time"';

	    access_log /data/log/nginx/access.log main;

		server{
			listen 5306;
			#allow 116.62.111.17; 
			allow 0.0.0.0; 
			#deny all;
			proxy_connect_timeout 10s; #后端服务器连接的超时时间_发起握手等候响应超时时间
			#proxy_read_timeout 180s; #连接成功后_等候后端服务器响应时间_其实已经进入后端的排队之中等候处理(也可以说是后端服务器处理请求的时间)
			#proxy_send_timeout 180s; #后端服务器数据回传时间_就是在规定时间之内后端服务器必须传完所有的数据
			proxy_timeout 1800s; #代理超时
			proxy_pass backend;

		
			#access_log /data/log/nginx/$2-access.log main;
		}
		upstream backend02{
			server r-bp1df75994.redis.rds.aliyuncs.com:6379;
		}
		server{
			listen 5307;
			#allow 116.62.111.17; 
			allow 0.0.0.0; 
			#deny all;
			proxy_connect_timeout 10s; #后端服务器连接的超时时间_发起握手等候响应超时时间
			#proxy_read_timeout 180s; #连接成功后_等候后端服务器响应时间_其实已经进入后端的排队之中等候处理(也可以说是后端服务器处理请求的时间)
			#proxy_send_timeout 180s; #后端服务器数据回传时间_就是在规定时间之内后端服务器必须传完所有的数据
			proxy_timeout 1800s; #代理超时
			proxy_pass backend02;
		}
	}



	

# Settings for a TLS enabled server.
#
#    server {
#        listen       443 ssl http2 default_server;
#        listen       [::]:443 ssl http2 default_server;
#        server_name  _;
#        root         /usr/share/nginx/html;
#
#        ssl_certificate "/etc/pki/nginx/server.crt";
#        ssl_certificate_key "/etc/pki/nginx/private/server.key";
#        ssl_session_cache shared:SSL:1m;
#        ssl_session_timeout  10m;
#        ssl_ciphers HIGH:!aNULL:!MD5;
#        ssl_prefer_server_ciphers on;
#
#        # Load configuration files for the default server block.
#        include /etc/nginx/default.d/*.conf;
#
#        location / {
#        }
#
#        error_page 404 /404.html;
#            location = /40x.html {
#        }
#
#        error_page 500 502 503 504 /50x.html;
#            location = /50x.html {
#        }
#    }

  

posted @ 2019-11-12 18:00  逐梦~前行  阅读(636)  评论(0编辑  收藏  举报