iTranslated by AI

The content below is an AI-generated translation. This is an experimental feature, and may contain errors. View original article
🐈‍⬛

[Personal Project] I built a service to expose local servers to the internet—please check it out!

に公開
2024/03/18
3件

Service Overview

I created a service called "TCP Exposer" that allows servers with only private IP addresses (hereafter referred to as local servers) to be accessed from the internet.
I've written this article to share it with as many people as possible and to promote the service.
Below is a screenshot of the service's top page.

Top Page
The service's top page

Usage is simple: just execute a command like ssh -R 80:localhost:8080 anonymous@tcpexposer.com on your local server.
By running this, the local server's port 8080 becomes accessible from the internet, as shown in the sequence diagram below.

I've also documented the software and other services used for development and operation, along with the reasons for their selection, in this Zenn article.
Please check it out if you're interested.

Development Background

It all started with my desire to publish web services with as little cost as possible.
Static web pages can be published for free using services like GitHub Pages, but dynamic ones require a database running constantly, which might exceed the free tiers of cloud services.
(In reality, though, depending on the service, you could probably operate at low or no cost by cleverly utilizing Heroku's free PostgreSQL tier, for example.)

Driven by this challenge, I considered whether I could solve it by using unused Raspberry Pis or PCs as servers and making them public on the internet.
To make a server public on the internet, a global IP address is generally required.
However, many ISPs charge extra for global IP addresses, or sometimes only private IP addresses are available.

When you only have a private IP address, you need to set up a separate server with a global IP address and connect it to your local server via a VPN or similar method.
Then, by routing through that global server, the local server can be accessed from the internet.

Since the global server only handles encryption and forwarding (and its required specs are low as long as the number of forwarding targets is small), I thought I could share this solution with others facing the same problem. This is why I developed this service.
(By the way, the service I originally intended to build seemed mediocre, so I didn't end up developing it.)

I discovered similar services during development and hesitated, but since I found some points lacking in them, I decided to continue and launch this service.

Differences from Similar Services

Types of Services

I consider services like ngrok or VPN services to be competitors.

Both ngrok and this service establish a communication path that bypasses firewalls and NAT between the local server and a proxy server.
Local server clients then access the server through this path.
These services are essentially for people who want to make applications running on a local server publicly available.

For use cases such as accessing a home server from outside, VPN services are also competitors.
Unlike VPN services, this service does not provide authentication; however, if you are exposing the port for an SSH service, only those with the credentials for the SSH server itself can gain access.

Introduction to Similar Services

Among similar services, I believe the following are relatively well-known within my knowledge.
Note that while I have used localhost.run a bit, my understanding is mostly based on skimming the official documentation, so there might be inaccuracies.

  • ngrok

    I think this is the most famous service of this type.
    Like this service, it can expose not only HTTP(S) servers but also TCP servers.
    ngrok requires installing a dedicated client software on the local server, whereas this service works with a standard SSH client, so no installation is necessary.

  • Cloudflare Zero Trust / Cloudflare Tunnel

    Cloudflare, famous for its CDN service, also offers a similar service.
    It seems it can be used both like this service and like a VPN service.
    It requires obtaining a domain and installing dedicated client software on the local server.

  • Tailscale

    It is a VPN service.
    Therefore, it cannot make local servers widely public to the general audience, nor is it intended for that purpose.
    However, unlike this service, communication between the local server and its client doesn't go through Tailscale, which seems to result in faster speeds.
    On the other hand, you need to install a dedicated client on both the local server and the client side.

  • localhost.run

    It is very similar to this service.
    Since it uses a standard SSH client, no dedicated software is needed, and the commands to execute are almost identical to this service.
    localhost.run cannot expose TCP servers, but this service can.

Features of This Service

I believe the features of this service are as follows.

  • No dedicated client required.

    This is the main selling point.
    It can be used with software (SSH client) that is pre-installed on Windows, Mac, and Linux.
    Personally, I find installing dedicated software to be a bit of a hurdle, but that's not necessary here.
    Additionally, it can be used even on company PCs where you might not have the freedom to install software.
    Even in proxy environments, you can connect by following the settings described on this website.

  • No user registration required.

    While there are some limitations, I wanted to lower the barrier to entry, so no registration is required for trial use.

  • TCP port numbers can be exposed.

    There are other similar services besides those listed above, but they often only support HTTP(S).
    This service also supports TCP in addition to that.

Finally

Please try using TCP Exposer in the following cases:

  • You want to publish a web service using your home PC.
  • You want to access your home PC from outside.
  • You want to temporarily allow access from stakeholders or other apps for trials of applications currently under development on a local PC.

Also, I've documented the software and other services used for development and operation, along with the reasons for their selection, in this Zenn article.
Please check it out if you're interested.

GitHubで編集を提案

Discussion

kanonjikanonji

http(s)://foo.localhostでどうやって外からアクセス出来るのかちょっと悩んでしまいました。
サービスのWebサイトを見たのでもう理解しましたが、この記事のスクリーンショットが更新されていたら助かりそうです。
また、シークエンス図でローカルサーバーのクライアントとローカルサーバーが登場していて、ぱっと見ではローカルで完結してそうに見えてしまいました。
これは個人の感覚によるとは思いますが、私としては例えばリモートのクライアントなどリモートの存在だと分かる名前だと、分かりやすいかもと思います。

2
teasyteasy

フィードバックありがとうございます。
スクリーンショットの画像は開発環境時のもので、ご指摘の通り間違いがあったので差し替えました。
また、シークエンス図内の文言も誤解を与えにくいように「ローカルサーバーのクライアント」から「リモートクライアント」に変更しました。

1
kanonjikanonji

ありがとうございます。助かります。
サービスの方も、Webhookを受信するLambda functionsを書く前に、一旦手元のHTTPサーバーで受信してみる事が出来て助かりました。

1