我正在使用localtunnel v1。但是我发现v2允许你自定义子域,我需要这个功能。
我按照存储库README
中描述的教程进行操作,但它在几个部分让我感到困惑,最后它没有用。
第一步是运行一些网络应用程序:检查,在端口号上。8000。
然后,它说明了主机名:
Localtunnel 对主机名做了一些事情,所以你想设置两个主机名。一个用于本地隧道注册,一个用于您的本地隧道。通常它需要一个通配符,但我们只会为这个示例隧道硬编码一个主机名。
示例.localtunnel.local -> 127.0.0.1
localtunnel.local -> 127.0.0.1您可以在 /etc/hosts 中执行此操作,或者使用那个花哨的 ghost 实用程序。
我在这里迷路了,但我仍然编辑了我的/etc/hosts
:
127.0.0.1 localhost
127.0.1.1 my-pc-name
127.0.0.1 example.localtunnel.local
127.0.0.1 localtunnel.local
下一步...
现在您可以启动服务器了。它基于 config 目录中的配置文件。您可以自己制作,但这个配置为在端口 9999 上运行服务器,并且需要主机名 localtunnel.local
银杏配置/default.conf.py
哪一个?无论如何...我根据 localtunnel repo 目录中的文件创建了 myconfig.conf.py /deploy
:
port = 9999
hostname = 'localtunnel.local'
service = 'localtunnel.server.TunnelBroker'
但是,当我运行时:
lt --broker 127.0.0.1:9999 --name example 8000
我有:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/gevent/greenlet.py", line 390, in run
result = self._run(*self.args, **self.kwargs)
File "/usr/local/lib/python2.7/dist-packages/localtunnel/client.py", line 53, in listen
msg = self.ws.receive(msg_obj=True)
TypeError: receive() got an unexpected keyword argument 'msg_obj'
<Greenlet at 0xb6e0db1cL: <bound method TunnelClient.listen of <localtunnel.client.TunnelClient object at 0xb6def52c>>> failed with TypeError
而在银杏过程中:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/gevent/pywsgi.py", line 438, in handle_one_response
self.run_application()
File "/usr/local/lib/python2.7/dist-packages/ws4py/server/geventserver.py", line 85, in run_application
self.result = self.application(self.environ, start_response_for_upgrade)
File "/usr/local/lib/python2.7/dist-packages/ws4py/server/wsgi/middleware.py", line 131, in __call__
environ.copy()))
TypeError: handle_websocket() takes exactly 3 arguments (2 given)
<BrokerFrontend fileno=6 address=0.0.0.0:9999>: Failed to handle request:
request = GET /t/example HTTP/1.1 from ('127.0.0.1', 35907)
application = <ws4py.server.wsgi.middleware.WebSocketUpgradeMiddleware object at 0x95bc2ac>
127.0.0.1 - - [2012-05-14 17:18:18] "GET /t/example HTTP/1.1" 101 162 0.000933
而且,显然,http://example.localtunnel.local:9999不起作用。
如何解决这个问题?我必须在哪里修改才能更改最终的子域?
对不起令人毛骨悚然的英语。
编辑
我遵循了保罗的建议并进行了降级。但是,虽然发生了变化,但错误仍然存在。银杏工艺:
$ ginkgo eco.conf.py
Starting process with eco.conf.py...
127.0.0.1 - - [2012-05-22 20:21:11] "GET /t/example HTTP/1.1" 400 116 0.000190
本地隧道进程:
$ lt --broker 127.0.0.1:9999 --name example 8000
Traceback (most recent call last):
File "/usr/local/bin/lt", line 9, in <module>
load_entry_point('localtunnel==0.4.0', 'console_scripts', 'lt')()
File "/usr/local/lib/python2.7/dist-packages/localtunnel/client.py", line 31, in main
client.serve_forever()
File "/usr/local/lib/python2.7/dist-packages/ginkgo/core.py", line 188, in serve_forever
self.start()
File "/usr/local/lib/python2.7/dist-packages/ginkgo/core.py", line 124, in start
ready = not self.do_start()
File "/usr/local/lib/python2.7/dist-packages/localtunnel/client.py", line 42, in do_start
self.ws.connect()
File "/usr/local/lib/python2.7/dist-packages/ws4py-0.1.5-py2.7.egg/ws4py/client/threadedclient.py", line 72, in connect
self.process_response_line(response_line)
File "/usr/local/lib/python2.7/dist-packages/ws4py-0.1.5-py2.7.egg/ws4py/client/__init__.py", line 61, in process_response_line
raise HandshakeError("Invalid response status: %s %s" % (code, status))
ws4py.exc.HandshakeError: Invalid response status: 400 Bad Handshake
虽然现在 ginkgo 没有报错,但是 localtunnel 还是会报出与之前的报错不同的报错。显然它试图在连接过程中获取“/t/example”。