在代理后面使用Go App Engine的问题

huangapple go评论155阅读模式
英文:

Problems using Go App Engine behind a proxy

问题

我正在尝试运行托管在https://github.com/googlesamples/cloud-polymer-go的示例应用程序,但在代理后运行时,我遇到以下错误:

$ goapp serve dispatch.yaml frontend/app.yaml backend/app.yaml
INFO 2015-10-13 13:04:19,461 devappserver2.py:763] Skipping SDK update check.
INFO 2015-10-13 13:04:19,526 api_server.py:205] Starting API server at: http://localhost:59441
INFO 2015-10-13 13:04:19,527 dispatcher.py:185] Starting dispatcher running at: http://localhost:8080
INFO 2015-10-13 13:04:19,529 dispatcher.py:197] Starting module "frontend" running at: http://localhost:8081
INFO 2015-10-13 13:04:19,534 dispatcher.py:197] Starting module "default" running at: http://localhost:8082
INFO 2015-10-13 13:04:19,534 admin_server.py:116] Starting admin server at: http://localhost:8000
INFO 2015-10-13 13:04:23,859 module.py:786] frontend: "GET / HTTP/1.1" 304 -
INFO 2015-10-13 13:04:23,870 module.py:786] frontend: "GET /elements/post-list.html HTTP/1.1" 304 -
INFO 2015-10-13 13:04:24,377 module.py:786] frontend: "GET /elements/post-service.html HTTP/1.1" 304 -
INFO 2015-10-13 13:04:24,377 module.py:786] frontend: "GET /elements/post-form.html HTTP/1.1" 304 -
INFO 2015-10-13 13:04:24,377 module.py:786] frontend: "GET /elements/post-card.html HTTP/1.1" 304 -
WARNING 2015-10-13 13:04:26,344 dispatcher.py:762] Skipping dispatch.yaml rules because /_ah/api/static/proxy.html is not a dispatchable path.
socket.error 101
Traceback (most recent call last):
File "/home/robert/applib/appEngine/go_appengine/lib/cherrypy/cherrypy/wsgiserver/wsgiserver2.py", line 1302, in communicate
req.respond()
File "/home/robert/applib/appEngine/go_appengine/lib/cherrypy/cherrypy/wsgiserver/wsgiserver2.py", line 831, in respond
self.server.gateway(self).respond()
File "/home/robert/applib/appEngine/go_appengine/lib/cherrypy/cherrypy/wsgiserver/wsgiserver2.py", line 2117, in respond
for chunk in response:
File "/home/robert/applib/appEngine/go_appengine/google/appengine/tools/devappserver2/endpoints/endpoints_server.py", line 121, in call
yield self.dispatch(request, start_response)
File "/home/robert/applib/appEngine/go_appengine/google/appengine/tools/devappserver2/endpoints/endpoints_server.py", line 138, in dispatch
start_response)
File "/home/robert/applib/appEngine/go_appengine/google/appengine/tools/devappserver2/endpoints/endpoints_server.py", line 172, in dispatch_non_api_requests
return dispatch_function(request, start_response)
File "/home/robert/applib/appEngine/go_appengine/google/appengine/tools/devappserver2/endpoints/endpoints_server.py", line 212, in handle_api_static_request
response, body = discovery_api.get_static_file(request.relative_url)
File "/home/robert/applib/appEngine/go_appengine/google/appengine/tools/devappserver2/endpoints/discovery_api_proxy.py", line 113, in get_static_file
connection.request('GET', path, None, {})
File "/usr/lib/python2.7/httplib.py", line 979, in request
self._send_request(method, url, body, headers)
File "/usr/lib/python2.7/httplib.py", line 1013, in _send_request
self.endheaders(body)
File "/usr/lib/python2.7/httplib.py", line 975, in endheaders
self._send_output(message_body)
File "/usr/lib/python2.7/httplib.py", line 835, in _send_output
self.send(msg)
File "/usr/lib/python2.7/httplib.py", line 797, in send
self.connect()
File "/usr/lib/python2.7/httplib.py", line 1178, in connect
self.timeout, self.source_address)
File "/usr/lib/python2.7/socket.py", line 571, in create_connection
raise err
error: [Errno 101] Network is unreachable

变量设置如下:

$ echo $http_proxy
http://asusis-isa2.personal.com.py:8080/
$ echo $https_proxy
http://asusis-isa2.personal.com.py:8080/

已正确设置。

我可以使用直接的互联网连接。

我使用的是Ubuntu 14.04。

英文:

I'm trying to run the example application hosted at: https://github.com/googlesamples/cloud-polymer-go, but when running it behind a proxy, I get the following errors:

$ goapp serve dispatch.yaml frontend/app.yaml backend/app.yaml
INFO     2015-10-13 13:04:19,461 devappserver2.py:763] Skipping SDK update check.
INFO     2015-10-13 13:04:19,526 api_server.py:205] Starting API server at: http://localhost:59441
INFO     2015-10-13 13:04:19,527 dispatcher.py:185] Starting dispatcher running at: http://localhost:8080
INFO     2015-10-13 13:04:19,529 dispatcher.py:197] Starting module "frontend" running at: http://localhost:8081
INFO     2015-10-13 13:04:19,534 dispatcher.py:197] Starting module "default" running at: http://localhost:8082
INFO     2015-10-13 13:04:19,534 admin_server.py:116] Starting admin server at: http://localhost:8000
INFO     2015-10-13 13:04:23,859 module.py:786] frontend: "GET / HTTP/1.1" 304 -
INFO     2015-10-13 13:04:23,870 module.py:786] frontend: "GET /elements/post-list.html HTTP/1.1" 304 -
INFO     2015-10-13 13:04:24,377 module.py:786] frontend: "GET /elements/post-service.html HTTP/1.1" 304 -
INFO     2015-10-13 13:04:24,377 module.py:786] frontend: "GET /elements/post-form.html HTTP/1.1" 304 -
INFO     2015-10-13 13:04:24,377 module.py:786] frontend: "GET /elements/post-card.html HTTP/1.1" 304 -
WARNING  2015-10-13 13:04:26,344 dispatcher.py:762] Skipping dispatch.yaml rules because /_ah/api/static/proxy.html is not a dispatchable path.
socket.error 101
Traceback (most recent call last):
  File "/home/robert/applib/appEngine/go_appengine/lib/cherrypy/cherrypy/wsgiserver/wsgiserver2.py", line 1302, in communicate
    req.respond()
  File "/home/robert/applib/appEngine/go_appengine/lib/cherrypy/cherrypy/wsgiserver/wsgiserver2.py", line 831, in respond
    self.server.gateway(self).respond()
  File "/home/robert/applib/appEngine/go_appengine/lib/cherrypy/cherrypy/wsgiserver/wsgiserver2.py", line 2117, in respond
    for chunk in response:
  File "/home/robert/applib/appEngine/go_appengine/google/appengine/tools/devappserver2/endpoints/endpoints_server.py", line 121, in __call__
    yield self.dispatch(request, start_response)
  File "/home/robert/applib/appEngine/go_appengine/google/appengine/tools/devappserver2/endpoints/endpoints_server.py", line 138, in dispatch
    start_response)
  File "/home/robert/applib/appEngine/go_appengine/google/appengine/tools/devappserver2/endpoints/endpoints_server.py", line 172, in dispatch_non_api_requests
    return dispatch_function(request, start_response)
  File "/home/robert/applib/appEngine/go_appengine/google/appengine/tools/devappserver2/endpoints/endpoints_server.py", line 212, in handle_api_static_request
    response, body = discovery_api.get_static_file(request.relative_url)
  File "/home/robert/applib/appEngine/go_appengine/google/appengine/tools/devappserver2/endpoints/discovery_api_proxy.py", line 113, in get_static_file
    connection.request('GET', path, None, {})
  File "/usr/lib/python2.7/httplib.py", line 979, in request
    self._send_request(method, url, body, headers)
  File "/usr/lib/python2.7/httplib.py", line 1013, in _send_request
    self.endheaders(body)
  File "/usr/lib/python2.7/httplib.py", line 975, in endheaders
    self._send_output(message_body)
  File "/usr/lib/python2.7/httplib.py", line 835, in _send_output
    self.send(msg)
  File "/usr/lib/python2.7/httplib.py", line 797, in send
    self.connect()
  File "/usr/lib/python2.7/httplib.py", line 1178, in connect
    self.timeout, self.source_address)
  File "/usr/lib/python2.7/socket.py", line 571, in create_connection
    raise err
error: [Errno 101] Network is unreachable

The variables:

$ echo $http_proxy 
http://asusis-isa2.personal.com.py:8080/
$ echo $https_proxy 
http://asusis-isa2.personal.com.py:8080/

Are correctly set.

I works with a direct Internet connection.

I'm under Ubuntu 14.04.

答案1

得分: 2

编辑 看起来在使用URLFetch时SDK存在一个缺陷,涉及使用代理。

https://code.google.com/p/googleappengine/issues/detail?id=544

尝试设置这些环境变量的大写版本,HTTP_PROXYHTTPS_PROXYgcloud启动器要求以这种方式设置,所以我认为goapp也是如此。

使用HTTP代理

如果您在HTTP代理后面运行gcloud preview app,您必须告诉gcloud preview app代理的名称。要为gcloud preview app设置HTTP代理,请设置http_proxyhttps_proxy环境变量。请注意,您必须为app.yaml文件指定完整路径。

在Windows中(在命令提示符中):

$ set HTTP_PROXY=http://cache.mycompany.com:3128
$ set HTTPS_PROXY=http://cache.mycompany.com:3128
$ gcloud preview app deploy DIRECTORY/app.yaml

在Mac OS X(在终端)或Linux中使用命令行:

$ export HTTP_PROXY="http://cache.mycompany.com:3128"
$ export HTTPS_PROXY="http://cache.mycompany.com:3128"
$ gcloud preview app deploy DIRECTORY/app.yaml
英文:

EDIT Looks like there is a defect in the SDK around using a proxy with URLFetch.

https://code.google.com/p/googleappengine/issues/detail?id=544

Try setting the uppercase versions of those environment variables, HTTP_PROXY and HTTPS_PROXY. The gcloud launcher requires them that way so I assume goapp does as well.

> Using an HTTP proxy
>
> If you are running gcloud preview app behind an HTTP proxy, you must
> tell gcloud preview app the name of the proxy. To set an HTTP proxy
> for gcloud preview app, set the http_proxy and https_proxy environment
> variables. Note that you must specify the full path for the app.yaml
> file.
>
> Using Windows (in Command Prompt):
>
> $ set HTTP_PROXY=http://cache.mycompany.com:3128
> $ set HTTPS_PROXY=http://cache.mycompany.com:3128
> $ gcloud preview app deploy DIRECTORY/app.yaml
>
> Using the command line in Mac OS X (in Terminal) or Linux:
>
> $ export HTTP_PROXY="http://cache.mycompany.com:3128"
> $ export HTTPS_PROXY="http://cache.mycompany.com:3128"
> $ gcloud preview app deploy DIRECTORY/app.yaml

huangapple
  • 本文由 发表于 2015年10月13日 21:08:26
  • 转载请务必保留本文链接:https://go.coder-hub.com/33103557.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定