nginx順方向エージェント(インターネットエージェント)逆方向エージェント

5842 ワード

順方向エージェント(インターネットエージェント)
順方向プロキシnginx設定
user  nginx;
worker_processes  1;

error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;
 
events {
	use epoll;
	worker_connections 1024;
}
 
http {
	resolver 8.8.8.8;
	server {
		listen 8088; 
		location / {
			proxy_pass http://$http_host$request_uri;
		}
	}
}

  • 順方向エージェントの特徴は、dns解析resover
  • を増加させる。
  • serverはserver_がありません。name
  • proxy_pass命令
  • ネットワークサーバの設定
    vim/etc/profile追加
    #     
    http_proxy=http://[email protected]:8088/
    # http_proxy=http://   :  @ip:  /
    #         http_proxy=http://   @ip:  /
    https_proxy=http://[email protected]:8088/
    export http_proxy https_proxy
    
  • http_proxy http代理店
  • https_proxy https代理店
  • ノ_proxyは代理のドメイン名またはipを使用しません。
  • 逆プロキシ
    #       
    gzip              on;  
    gzip_min_length   1000;  
    gzip_types        text/plain text/css application/x-javascript;
    
    #            
    #weigth      ,             
    upstream test{
        server 192.168.0.194:8080 weight=1;
        server 192.168.0.195:8080 weight=1; 
        server 192.168.0.195:8085 weight=1; 
    }
       
    server {
        #   80  
        listen       80;
        #                       
        server_name  localhost,www.baidu.com; 
        #    Nginx     
        location /nginxstatus{
             stub_status on;
             access_log on;
             auth_basic "nginxstatus";
             auth_basic_user_file htpasswd;
        }
        #   jsp   ,tomcat       jsp  
        location / {
            index index.jsp;
            # proxy_pass   http://192.168.0.194:8080;         
            proxy_pass   http://test;    #         , upstream     
            #               
            proxy_redirect             off; 
            #   Web       X-Forwarded-For      IP
            proxy_set_header           Host $host; 
            proxy_set_header           X-Real-IP $remote_addr; 
            proxy_set_header           X-Forwarded-For $proxy_add_x_forwarded_for; 
            client_max_body_size       10m; #                
            client_body_buffer_size    128k; #                  
            proxy_connect_timeout      300; #nginx            (      )
            proxy_send_timeout         300; #           (      )
            proxy_read_timeout         300; #     ,         (      )
            proxy_buffer_size          4k; #       (nginx)             
            proxy_buffers              4 32k; #proxy_buffers   ,     32k    ,    
            proxy_busy_buffers_size    64k; #        (proxy_buffers*2)
            proxy_temp_file_write_size 64k; #         ,     ,  upstream    
        }
    }