zoukankan      html  css  js  c++  java
  • multiple levlve proxy route deploy

    wget http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.2-2.el5.rf.x86_64.rpm

    rpm -ivh ./rpmforge....

    yum install nload -y

    rz nginx

    tar -zxvf ./nginx-1.3.0.tar.gz && cd nginx-1.3.0 && ./configure --without-http_rewrite_module && make && make install && cd /usr/local/nginx && pwd && vi ./conf/nginx.conf

    tar -zxvf ./nginx-1.3.0.tar.gz && cd nginx-1.3.0 && ./configure  && make && make install && cd /usr/local/nginx && pwd && vi ./conf/nginx.conf

    Traceback (most recent call last):
      File "./test_proxy.py", line 10, in <module>
        html=urllib2.urlopen(req).read()
      File "/opt/python2.6/lib/python2.6/urllib2.py", line 126, in urlopen
        return _opener.open(url, data, timeout)
      File "/opt/python2.6/lib/python2.6/urllib2.py", line 391, in open
        response = self._open(req, data)
      File "/opt/python2.6/lib/python2.6/urllib2.py", line 409, in _open
        '_open', req)
      File "/opt/python2.6/lib/python2.6/urllib2.py", line 369, in _call_chain
        result = func(*args)
      File "/opt/python2.6/lib/python2.6/urllib2.py", line 1161, in http_open
        return self.do_open(httplib.HTTPConnection, req)
      File "/opt/python2.6/lib/python2.6/urllib2.py", line 1136, in do_open
        raise URLError(err)
    urllib2.URLError: <urlopen error [Errno 113] No route to host>

    service iptables stop

    server {
        resolver 202.106.0.20;
        resolver_timeout 5s;

        listen 0.0.0.0:80;

        location / {
            proxy_pass $scheme://$host$request_uri;
            proxy_set_header Host $http_host;

            proxy_buffers 256 4k;
            proxy_max_temp_file_size 0;

            proxy_connect_timeout 30;

            proxy_cache_valid 200 302 10m;
            proxy_cache_valid 301 1h;
            proxy_cache_valid any 1m;
        }

    }}

    ./sbin/nginx -t

    ./sbin/nginx -c ./conf/nginx.conf

    ps -ef|grep nginx

    #!/usr/bin/env python
    #encoding=utf-8
    import urllib2
    while True:
            proxy_handler=urllib2.ProxyHandler({'http' : 'http://127.0.0.1:80'})
            opener = urllib2.build_opener(proxy_handler)
            opener.addheaders = [('User-agent', 'Mozilla/5.0')]
            urllib2.install_opener(opener)
            url="http://www.baidu.com"
            req=urllib2.Request(url)
            html=urllib2.urlopen(req).read()
            print html
            import time
            time.sleep(0.1)

  • 相关阅读:
    开源搜索引擎Solr的快速搭建及集成到企业门户最佳实施方案--转载
    Java开发WebService的几种方法--转载
    HBase Java简单示例--转载
    Eclipse快捷键大全--转载
    Java中List、Set和Map的区别--转载
    ArrayList和Iterator的用法
    日期格式化
    java中的值传递和引用传递问题
    Servlet,过滤器,监听器,拦截器的区别
    Java过滤器与SpringMVC拦截器之间的关系与区别
  • 原文地址:https://www.cnblogs.com/lexus/p/2528923.html
Copyright © 2011-2022 走看看