Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

nodeenv -p server is blocking connection from python's urllib2 #127

Closed
darkowic opened this issue Aug 31, 2015 · 6 comments
Closed

nodeenv -p server is blocking connection from python's urllib2 #127

darkowic opened this issue Aug 31, 2015 · 6 comments

Comments

@darkowic
Copy link

Hello

I have spotted issue while installed nodeenv on my computer. I'm getting error while installation when python is trying to connect to "https://nodejs.org/dist/latest/":

Traceback (most recent call last):
  File "/home/dariusz/.virtualenvs/wallpaper/bin/nodeenv", line 9, in <module>
    load_entry_point('nodeenv==0.13.3', 'console_scripts', 'nodeenv')()
  File "/home/dariusz/.virtualenvs/wallpaper/src/nodeenv/nodeenv.py", line 875, in main
    opt.node = get_last_stable_node_version()
  File "/home/dariusz/.virtualenvs/wallpaper/src/nodeenv/nodeenv.py", line 813, in get_last_stable_node_version
    response = urlopen('https://%s/dist/latest/' % (src_domain))
  File "/usr/lib/python2.7/urllib2.py", line 154, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/lib/python2.7/urllib2.py", line 437, in open
    response = meth(req, response)
  File "/usr/lib/python2.7/urllib2.py", line 550, in http_response
    'http', request, response, code, msg, hdrs)
  File "/usr/lib/python2.7/urllib2.py", line 475, in error
    return self._call_chain(*args)
  File "/usr/lib/python2.7/urllib2.py", line 409, in _call_chain
    result = func(*args)
  File "/usr/lib/python2.7/urllib2.py", line 558, in http_error_default
    raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 403: Forbidden

I connect by curl using HEAD from python "curl -H "User-agent: Python-urllib/2" "https://nodejs.org/dist/latest/"" and this is what i got:
http://pastebin.com/Wmw41m6b

<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js ie6 oldie" lang="en-US"> <![endif]-->
<!--[if IE 7]>    <html class="no-js ie7 oldie" lang="en-US"> <![endif]-->
<!--[if IE 8]>    <html class="no-js ie8 oldie" lang="en-US"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en-US"> <!--<![endif]-->
<head>
<title>Access denied | nodejs.org used CloudFlare to restrict access</title>
<meta charset="UTF-8" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1" />
<meta name="robots" content="noindex, nofollow" />
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1" />
<link rel="stylesheet" id="cf_styles-css" href="/cdn-cgi/styles/cf.errors.css" type="text/css" media="screen,projection" />
<!--[if lt IE 9]><link rel="stylesheet" id='cf_styles-ie-css' href="/cdn-cgi/styles/cf.errors.ie.css" type="text/css" media="screen,projection" /><![endif]-->
<style type="text/css">body{margin:0;padding:0}</style>
<!--[if lte IE 9]><script type="text/javascript" src="/cdn-cgi/scripts/jquery.min.js"></script><![endif]-->
<!--[if gte IE 10]><!--><script type="text/javascript" src="/cdn-cgi/scripts/zepto.min.js"></script><!--<![endif]-->
<script type="text/javascript" src="/cdn-cgi/scripts/cf.common.js"></script>

</head>
<body>
  <div id="cf-wrapper">
    <div class="cf-alert cf-alert-error cf-cookie-error" id="cookie-alert" data-translate="enable_cookies">Please enable cookies.</div>
    <div id="cf-error-details" class="cf-error-details-wrapper">
      <div class="cf-wrapper cf-header cf-error-overview">
        <h1>
          <span class="cf-error-type" data-translate="error">Error</span>
          <span class="cf-error-code">1010</span>
          <small class="heading-ray-id">Ray ID: 21e80c506990235a &bull; 2015-08-31 10:28:21 UTC</small>
        </h1>
        <h2 class="cf-subheadline" data-translate="error_desc">Access denied</h2>
      </div><!-- /.header -->

      <section></section><!-- spacer -->

      <div class="cf-section cf-wrapper">
        <div class="cf-columns two">
          <div class="cf-column">
            <h2 data-translate="what_happened">What happened?</h2>
            <p>The owner of this website (nodejs.org) has banned your access based on your browser's signature (21e80c506990235a-ua48).</p>
          </div>


        </div>
      </div><!-- /.section -->

      <div class="cf-error-footer cf-wrapper">
  <p>
    <span class="cf-footer-item">CloudFlare Ray ID: <strong>21e80c506990235a</strong></span>
    <span class="cf-footer-separator">&bull;</span>
    <span class="cf-footer-item"><span data-translate="your_ip">Your IP</span>: 91.189.255.2</span>
    <span class="cf-footer-separator">&bull;</span>
    <span class="cf-footer-item"><span data-translate="performance_security_by">Performance &amp; security by</span> <a data-orig-proto="https" data-orig-ref="www.cloudflare.com/5xx-error-landing?utm_source=error_footer" id="brand_link" target="_blank">CloudFlare</a></span>

  </p>
</div><!-- /.error-footer -->


    </div><!-- /#cf-error-details -->
  </div><!-- /#cf-wrapper -->

  <script type="text/javascript">
  window._cf_translation = {};


</script>

</body>
</html>

So, Server is blocking me. I can't install this.

@Valian
Copy link

Valian commented Aug 31, 2015

Same error here, yesterday everything was working ok. Any workaround?

@ekalinin
Copy link
Owner

Hi @darek504 @Valian

Thanks for report. Trying to find workarond.

@tracker1
Copy link

@ekalinin http://stackoverflow.com/questions/802134/changing-user-agent-on-urllib2-urlopen

import urllib2
req = urllib2.Request('http://www.example.com/')
req.add_header('User-Agent', 'nodeenv/1.0 (https://github.com/ekalinin/nodeenv)')
r = urllib2.urlopen(req)

@ekalinin
Copy link
Owner

Just pushed 0.13.4, it work for me atm.
Test it, please.

@darkowic
Copy link
Author

Thank you! It's working for me also ;)

@ekalinin
Copy link
Owner

Great!

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants