{"action":"created","comment":{"url":"https://api.github.com/repos/defunctzombie/localtunnel-server/pulls/comments/28199457","id":28199457,"diff_hunk":"@@ -140,9 +146,9 @@ function new_client(id, opt, cb) {\n }\n \n module.exports = function(opt) {\n-    opt = opt || {};\n+    options = opt || {};","path":"server.js","position":31,"original_position":31,"commit_id":"e33d5c32ef9afc095d6d21c351df3765f46f3fcb","original_commit_id":"e33d5c32ef9afc095d6d21c351df3765f46f3fcb","user":{"login":"defunctzombie","id":84792,"avatar_url":"https://avatars.githubusercontent.com/u/84792?v=3","gravatar_id":"","url":"https://api.github.com/users/defunctzombie","html_url":"https://github.com/defunctzombie","followers_url":"https://api.github.com/users/defunctzombie/followers","following_url":"https://api.github.com/users/defunctzombie/following{/other_user}","gists_url":"https://api.github.com/users/defunctzombie/gists{/gist_id}","starred_url":"https://api.github.com/users/defunctzombie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/defunctzombie/subscriptions","organizations_url":"https://api.github.com/users/defunctzombie/orgs","repos_url":"https://api.github.com/users/defunctzombie/repos","events_url":"https://api.github.com/users/defunctzombie/events{/privacy}","received_events_url":"https://api.github.com/users/defunctzombie/received_events","type":"User","site_admin":false},"body":"what is the purpose of this rename?","created_at":"2015-04-12T00:01:46Z","updated_at":"2015-04-12T00:01:46Z","html_url":"https://github.com/defunctzombie/localtunnel-server/pull/25#discussion_r28199457","pull_request_url":"https://api.github.com/repos/defunctzombie/localtunnel-server/pulls/25","_links":{"self":{"href":"https://api.github.com/repos/defunctzombie/localtunnel-server/pulls/comments/28199457"},"html":{"href":"https://github.com/defunctzombie/localtunnel-server/pull/25#discussion_r28199457"},"pull_request":{"href":"https://api.github.com/repos/defunctzombie/localtunnel-server/pulls/25"}}},"pull_request":{"url":"https://api.github.com/repos/defunctzombie/localtunnel-server/pulls/25","id":33110966,"html_url":"https://github.com/defunctzombie/localtunnel-server/pull/25","diff_url":"https://github.com/defunctzombie/localtunnel-server/pull/25.diff","patch_url":"https://github.com/defunctzombie/localtunnel-server/pull/25.patch","issue_url":"https://api.github.com/repos/defunctzombie/localtunnel-server/issues/25","number":25,"state":"open","locked":false,"title":"Add subdomain option","user":{"login":"CWSpear","id":495855,"avatar_url":"https://avatars.githubusercontent.com/u/495855?v=3","gravatar_id":"","url":"https://api.github.com/users/CWSpear","html_url":"https://github.com/CWSpear","followers_url":"https://api.github.com/users/CWSpear/followers","following_url":"https://api.github.com/users/CWSpear/following{/other_user}","gists_url":"https://api.github.com/users/CWSpear/gists{/gist_id}","starred_url":"https://api.github.com/users/CWSpear/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CWSpear/subscriptions","organizations_url":"https://api.github.com/users/CWSpear/orgs","repos_url":"https://api.github.com/users/CWSpear/repos","events_url":"https://api.github.com/users/CWSpear/events{/privacy}","received_events_url":"https://api.github.com/users/CWSpear/received_events","type":"User","site_admin":false},"body":"So you may remember me from like a year ago when I tried getting this to work and ended up giving up. I decided to revisit it recently and was getting new, but similar issues.\r\n\r\nUltimately, it appears that the server is *not* configured to handle sub-subdomains. The server needs to *know* that you're trying to use a subdomain as the entry point (i.e. the equivalent of `localtunnel.me`), otherwise it just thinks you're trying to connect to a proxy.\r\n\r\nThe code here allows you to specify a subdomain flag on the server side so that it knows about it.\r\n\r\n----\r\n\r\nAs a full example, here's my `nginx` config (based on [your example](https://github.com/defunctzombie/localtunnel-server/blob/v0.0.8/devops/nginx/sites/localtunnel)):\r\n\r\n```nginx\r\nproxy_http_version 1.1;\r\n\r\n# http://nginx.org/en/docs/http/websocket.html\r\nmap $http_upgrade $connection_upgrade {\r\n    default upgrade;\r\n    ''      close;\r\n}\r\n\r\nupstream lt-server {\r\n    server 127.0.0.1:1234;\r\n}\r\n\r\nserver {\r\n\tlisten 80;\r\n\r\n\tserver_name .tunnel.example.com;\r\n\r\n\tlocation / {\r\n\t\tproxy_pass http://lt-server/;\r\n\r\n\t\tproxy_set_header X-Real-IP $remote_addr;\r\n\t\tproxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\r\n\t\tproxy_set_header Host $http_host;\r\n\t\tproxy_set_header X-Forwarded-Proto http;\r\n\t\tproxy_set_header X-NginX-Proxy true;\r\n\t\tproxy_set_header Upgrade $http_upgrade;\r\n\t\tproxy_set_header Connection $connection_upgrade;\r\n\r\n\t\tproxy_redirect off;\r\n\t}\r\n}\r\n```\r\n\r\nBefore this PR, if I tried to run the server with this:\r\n\r\n```bash\r\nbin/server --port 1234\r\n```\r\n\r\nand ran this on the client:\r\n\r\n```bash\r\nlt --host \"http://tunnel.example.com\" --port 1803 --local-host example.dev --subdomain myproject\r\n```\r\n\r\nwith the intention of going to `http://myproject.tunnel.example.com` it **would not work**. The client would get a `502` response from the server and exit.\r\n\r\nThat's because on [line 36](https://github.com/defunctzombie/localtunnel-server/blob/v0.0.8/server.js#L36), is `false`, so the proxy is never created and on [line 40](https://github.com/defunctzombie/localtunnel-server/blob/v0.0.8/server.js#L40), `client_id` is `myproject.tunnel` when I want it to just be `myproject`.\r\n\r\nIn this PR, we add a `subdomain` option in the server options, so if we run this on the server:\r\n\r\n```bash\r\nbin/server --port 1234 --subdomain tunnel\r\n```\r\n\r\nwith the same command on the client, we now check to see if the subdomain in the request matches the `subdomain` parameter from the CLI, then it knows we want to create a client and thus does that. Then, when we go to our actual sub-subdomain we want the proxy to be at, `http://myproject.tunnel.example.com`, we remove `.{subdomain}` from the parsed subdomain value in the code, so the `client_id` is now `myproject` (because in this example `.tunnel` was removed) and we get the client `client_id` and everything works as expected.\r\n\r\nI tried to add some tests, but the test workflow wasn't making it easy, as it's all based off of a single server configuration.","created_at":"2015-04-11T22:14:48Z","updated_at":"2015-04-12T00:01:46Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f09a233f574b432f4496d921670ce9be3dcb5b2d","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/defunctzombie/localtunnel-server/pulls/25/commits","review_comments_url":"https://api.github.com/repos/defunctzombie/localtunnel-server/pulls/25/comments","review_comment_url":"https://api.github.com/repos/defunctzombie/localtunnel-server/pulls/comments{/number}","comments_url":"https://api.github.com/repos/defunctzombie/localtunnel-server/issues/25/comments","statuses_url":"https://api.github.com/repos/defunctzombie/localtunnel-server/statuses/e33d5c32ef9afc095d6d21c351df3765f46f3fcb","head":{"label":"CWSpear:subdomain","ref":"subdomain","sha":"e33d5c32ef9afc095d6d21c351df3765f46f3fcb","user":{"login":"CWSpear","id":495855,"avatar_url":"https://avatars.githubusercontent.com/u/495855?v=3","gravatar_id":"","url":"https://api.github.com/users/CWSpear","html_url":"https://github.com/CWSpear","followers_url":"https://api.github.com/users/CWSpear/followers","following_url":"https://api.github.com/users/CWSpear/following{/other_user}","gists_url":"https://api.github.com/users/CWSpear/gists{/gist_id}","starred_url":"https://api.github.com/users/CWSpear/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CWSpear/subscriptions","organizations_url":"https://api.github.com/users/CWSpear/orgs","repos_url":"https://api.github.com/users/CWSpear/repos","events_url":"https://api.github.com/users/CWSpear/events{/privacy}","received_events_url":"https://api.github.com/users/CWSpear/received_events","type":"User","site_admin":false},"repo":{"id":33792663,"name":"localtunnel-server","full_name":"CWSpear/localtunnel-server","owner":{"login":"CWSpear","id":495855,"avatar_url":"https://avatars.githubusercontent.com/u/495855?v=3","gravatar_id":"","url":"https://api.github.com/users/CWSpear","html_url":"https://github.com/CWSpear","followers_url":"https://api.github.com/users/CWSpear/followers","following_url":"https://api.github.com/users/CWSpear/following{/other_user}","gists_url":"https://api.github.com/users/CWSpear/gists{/gist_id}","starred_url":"https://api.github.com/users/CWSpear/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CWSpear/subscriptions","organizations_url":"https://api.github.com/users/CWSpear/orgs","repos_url":"https://api.github.com/users/CWSpear/repos","events_url":"https://api.github.com/users/CWSpear/events{/privacy}","received_events_url":"https://api.github.com/users/CWSpear/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/CWSpear/localtunnel-server","description":"server for localtunnel.me","fork":true,"url":"https://api.github.com/repos/CWSpear/localtunnel-server","forks_url":"https://api.github.com/repos/CWSpear/localtunnel-server/forks","keys_url":"https://api.github.com/repos/CWSpear/localtunnel-server/keys{/key_id}","collaborators_url":"https://api.github.com/repos/CWSpear/localtunnel-server/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/CWSpear/localtunnel-server/teams","hooks_url":"https://api.github.com/repos/CWSpear/localtunnel-server/hooks","issue_events_url":"https://api.github.com/repos/CWSpear/localtunnel-server/issues/events{/number}","events_url":"https://api.github.com/repos/CWSpear/localtunnel-server/events","assignees_url":"https://api.github.com/repos/CWSpear/localtunnel-server/assignees{/user}","branches_url":"https://api.github.com/repos/CWSpear/localtunnel-server/branches{/branch}","tags_url":"https://api.github.com/repos/CWSpear/localtunnel-server/tags","blobs_url":"https://api.github.com/repos/CWSpear/localtunnel-server/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/CWSpear/localtunnel-server/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/CWSpear/localtunnel-server/git/refs{/sha}","trees_url":"https://api.github.com/repos/CWSpear/localtunnel-server/git/trees{/sha}","statuses_url":"https://api.github.com/repos/CWSpear/localtunnel-server/statuses/{sha}","languages_url":"https://api.github.com/repos/CWSpear/localtunnel-server/languages","stargazers_url":"https://api.github.com/repos/CWSpear/localtunnel-server/stargazers","contributors_url":"https://api.github.com/repos/CWSpear/localtunnel-server/contributors","subscribers_url":"https://api.github.com/repos/CWSpear/localtunnel-server/subscribers","subscription_url":"https://api.github.com/repos/CWSpear/localtunnel-server/subscription","commits_url":"https://api.github.com/repos/CWSpear/localtunnel-server/commits{/sha}","git_commits_url":"https://api.github.com/repos/CWSpear/localtunnel-server/git/commits{/sha}","comments_url":"https://api.github.com/repos/CWSpear/localtunnel-server/comments{/number}","issue_comment_url":"https://api.github.com/repos/CWSpear/localtunnel-server/issues/comments{/number}","contents_url":"https://api.github.com/repos/CWSpear/localtunnel-server/contents/{+path}","compare_url":"https://api.github.com/repos/CWSpear/localtunnel-server/compare/{base}...{head}","merges_url":"https://api.github.com/repos/CWSpear/localtunnel-server/merges","archive_url":"https://api.github.com/repos/CWSpear/localtunnel-server/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/CWSpear/localtunnel-server/downloads","issues_url":"https://api.github.com/repos/CWSpear/localtunnel-server/issues{/number}","pulls_url":"https://api.github.com/repos/CWSpear/localtunnel-server/pulls{/number}","milestones_url":"https://api.github.com/repos/CWSpear/localtunnel-server/milestones{/number}","notifications_url":"https://api.github.com/repos/CWSpear/localtunnel-server/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/CWSpear/localtunnel-server/labels{/name}","releases_url":"https://api.github.com/repos/CWSpear/localtunnel-server/releases{/id}","created_at":"2015-04-11T21:10:39Z","updated_at":"2015-04-11T21:10:40Z","pushed_at":"2015-04-11T21:34:26Z","git_url":"git://github.com/CWSpear/localtunnel-server.git","ssh_url":"git@github.com:CWSpear/localtunnel-server.git","clone_url":"https://github.com/CWSpear/localtunnel-server.git","svn_url":"https://github.com/CWSpear/localtunnel-server","homepage":"http://localtunnel.me","size":414,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"defunctzombie:master","ref":"master","sha":"f7d0effa905f4f98ce2f01862824c52b65e92300","user":{"login":"defunctzombie","id":84792,"avatar_url":"https://avatars.githubusercontent.com/u/84792?v=3","gravatar_id":"","url":"https://api.github.com/users/defunctzombie","html_url":"https://github.com/defunctzombie","followers_url":"https://api.github.com/users/defunctzombie/followers","following_url":"https://api.github.com/users/defunctzombie/following{/other_user}","gists_url":"https://api.github.com/users/defunctzombie/gists{/gist_id}","starred_url":"https://api.github.com/users/defunctzombie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/defunctzombie/subscriptions","organizations_url":"https://api.github.com/users/defunctzombie/orgs","repos_url":"https://api.github.com/users/defunctzombie/repos","events_url":"https://api.github.com/users/defunctzombie/events{/privacy}","received_events_url":"https://api.github.com/users/defunctzombie/received_events","type":"User","site_admin":false},"repo":{"id":10726545,"name":"localtunnel-server","full_name":"defunctzombie/localtunnel-server","owner":{"login":"defunctzombie","id":84792,"avatar_url":"https://avatars.githubusercontent.com/u/84792?v=3","gravatar_id":"","url":"https://api.github.com/users/defunctzombie","html_url":"https://github.com/defunctzombie","followers_url":"https://api.github.com/users/defunctzombie/followers","following_url":"https://api.github.com/users/defunctzombie/following{/other_user}","gists_url":"https://api.github.com/users/defunctzombie/gists{/gist_id}","starred_url":"https://api.github.com/users/defunctzombie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/defunctzombie/subscriptions","organizations_url":"https://api.github.com/users/defunctzombie/orgs","repos_url":"https://api.github.com/users/defunctzombie/repos","events_url":"https://api.github.com/users/defunctzombie/events{/privacy}","received_events_url":"https://api.github.com/users/defunctzombie/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/defunctzombie/localtunnel-server","description":"server for localtunnel.me","fork":false,"url":"https://api.github.com/repos/defunctzombie/localtunnel-server","forks_url":"https://api.github.com/repos/defunctzombie/localtunnel-server/forks","keys_url":"https://api.github.com/repos/defunctzombie/localtunnel-server/keys{/key_id}","collaborators_url":"https://api.github.com/repos/defunctzombie/localtunnel-server/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/defunctzombie/localtunnel-server/teams","hooks_url":"https://api.github.com/repos/defunctzombie/localtunnel-server/hooks","issue_events_url":"https://api.github.com/repos/defunctzombie/localtunnel-server/issues/events{/number}","events_url":"https://api.github.com/repos/defunctzombie/localtunnel-server/events","assignees_url":"https://api.github.com/repos/defunctzombie/localtunnel-server/assignees{/user}","branches_url":"https://api.github.com/repos/defunctzombie/localtunnel-server/branches{/branch}","tags_url":"https://api.github.com/repos/defunctzombie/localtunnel-server/tags","blobs_url":"https://api.github.com/repos/defunctzombie/localtunnel-server/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/defunctzombie/localtunnel-server/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/defunctzombie/localtunnel-server/git/refs{/sha}","trees_url":"https://api.github.com/repos/defunctzombie/localtunnel-server/git/trees{/sha}","statuses_url":"https://api.github.com/repos/defunctzombie/localtunnel-server/statuses/{sha}","languages_url":"https://api.github.com/repos/defunctzombie/localtunnel-server/languages","stargazers_url":"https://api.github.com/repos/defunctzombie/localtunnel-server/stargazers","contributors_url":"https://api.github.com/repos/defunctzombie/localtunnel-server/contributors","subscribers_url":"https://api.github.com/repos/defunctzombie/localtunnel-server/subscribers","subscription_url":"https://api.github.com/repos/defunctzombie/localtunnel-server/subscription","commits_url":"https://api.github.com/repos/defunctzombie/localtunnel-server/commits{/sha}","git_commits_url":"https://api.github.com/repos/defunctzombie/localtunnel-server/git/commits{/sha}","comments_url":"https://api.github.com/repos/defunctzombie/localtunnel-server/comments{/number}","issue_comment_url":"https://api.github.com/repos/defunctzombie/localtunnel-server/issues/comments{/number}","contents_url":"https://api.github.com/repos/defunctzombie/localtunnel-server/contents/{+path}","compare_url":"https://api.github.com/repos/defunctzombie/localtunnel-server/compare/{base}...{head}","merges_url":"https://api.github.com/repos/defunctzombie/localtunnel-server/merges","archive_url":"https://api.github.com/repos/defunctzombie/localtunnel-server/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/defunctzombie/localtunnel-server/downloads","issues_url":"https://api.github.com/repos/defunctzombie/localtunnel-server/issues{/number}","pulls_url":"https://api.github.com/repos/defunctzombie/localtunnel-server/pulls{/number}","milestones_url":"https://api.github.com/repos/defunctzombie/localtunnel-server/milestones{/number}","notifications_url":"https://api.github.com/repos/defunctzombie/localtunnel-server/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/defunctzombie/localtunnel-server/labels{/name}","releases_url":"https://api.github.com/repos/defunctzombie/localtunnel-server/releases{/id}","created_at":"2013-06-16T22:30:48Z","updated_at":"2015-04-03T04:48:09Z","pushed_at":"2015-04-11T22:14:49Z","git_url":"git://github.com/defunctzombie/localtunnel-server.git","ssh_url":"git@github.com:defunctzombie/localtunnel-server.git","clone_url":"https://github.com/defunctzombie/localtunnel-server.git","svn_url":"https://github.com/defunctzombie/localtunnel-server","homepage":"http://localtunnel.me","size":761,"stargazers_count":155,"watchers_count":155,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":41,"mirror_url":null,"open_issues_count":9,"forks":41,"open_issues":9,"watchers":155,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/defunctzombie/localtunnel-server/pulls/25"},"html":{"href":"https://github.com/defunctzombie/localtunnel-server/pull/25"},"issue":{"href":"https://api.github.com/repos/defunctzombie/localtunnel-server/issues/25"},"comments":{"href":"https://api.github.com/repos/defunctzombie/localtunnel-server/issues/25/comments"},"review_comments":{"href":"https://api.github.com/repos/defunctzombie/localtunnel-server/pulls/25/comments"},"review_comment":{"href":"https://api.github.com/repos/defunctzombie/localtunnel-server/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/defunctzombie/localtunnel-server/pulls/25/commits"},"statuses":{"href":"https://api.github.com/repos/defunctzombie/localtunnel-server/statuses/e33d5c32ef9afc095d6d21c351df3765f46f3fcb"}}}}