WebCal
Ctrl K

ガイド

Expose multiple services

ガイド連携FAQサポート
価格ブログ
クイックスタートTop-Up and BillingAccelerating Access to Academic ResourcesQuick StartIntroductionMaintenance and TroubleshootingNetwork
プラットフォームJetBrain ProjectorTmpWebCal Scholars Program @2026Introduction to the Public Beta/Suqian Zone AAbout UsCopying Data Between InstancesAnalysis of Server Performance MetricsTidal Computing PowerLoad Balancing
中国製チップUsing Huawei MindIEHuawei Ascend NPUMooreThread GPU
環境設定CUDA/cuDNNMinicondaPython3.XInstalling DependenciesOverviewImages
エンタープライズ機能Flexible DeploymentElastic Deployment Release NotesBest Practices for Elastic DeploymentPerformance Metrics Monitoring
コンテナインスタンスJupyterLabRemote SSH ConnectionSave the imageScaling ConfigurationMulti-machine, multi-GPU parallel processingDaemonOverviewChange the billing methodMigration Example (Same Region)Migration ExamplesRemote DesktopReset the system
GPU の選び方GPU SelectionPerformance Testing
データUpload DataDownload DataPublic DataPublic Cloud Storage (Highly Recommended)Compression / DecompressionFile StorageLocal data diskOverview
ベストプラクティスFileZillaGitGromacsHuggingFaceKataGoLinux BasicsMPIOpenCLPyCharm Remote DevelopmentR (RStudio) InstallationSSH TunnelTensorBoardRemote Development with VSCodeVisdomVulkanXShellOpen PortsWeChat MessagesPerformanceExpose multiple servicesMoney-Saving TipsComputation Precision IssuesSoftware Sources

ベストプラクティス

Expose multiple services

2026/07/3030135の閲覧数

Currently, WebCal’s custom services only support exposing a single port. If you need to expose multiple services (such as HTTP services) within containers, you can use a proxy to implement a layer of routing and forwarding—for example, by using Nginx. Here, we provide a lighter-weight alternative. Assuming you have two services in your container, listening on ports 2000 and 3000 respectively, here’s an example using Flask:

# 模拟监听2000端口的服务
from flask import Flask
app = Flask(__name__)

@app.route('/v1/hello')
def hello():
    return 'I`m port 2000'

if __name__ == '__main__':
    app.run(port=2000)


# 模拟监听3000端口的服务
from flask import Flask
app = Flask(__name__)

@app.route('/v2/hello')
def hello():
    return 'I`m port 3000'

if __name__ == '__main__':
    app.run(port=3000)

The following starts a route-forwarding service on port 6006. If a route matches /v1/*, it is forwarded to the service listening on port 2000; if it matches /v2/*, it is forwarded to the service listening on port 3000. First, download the forwarding service program from the instance at wget https://webcal-public.ks3-cn-beijing.ksyuncs.com/tool/api-proxy/proxy_in_instance. Then, in the same directory as this service program file, create a file named config.yaml with the following content:

proxies:
   - host_and_port: http://127.0.0.1:2000  # 要代理到的服务地址
     route_path: /v1/*                     # 匹配什么路由就转发到此地址

   - host_and_port: http://127.0.0.1:3000  # 可设置多组,转发到不同的host
     route_path: /v2/*

Then start the forwarding service:

# 如果没下载转发程序,先下载
wget https://webcal-public.ks3-cn-beijing.ksyuncs.com/tool/api-proxy/proxy_in_instance

# 如果没有添加可执行权限,先添加权限
chmod +x proxy_in_instance

# 启动
./proxy_in_instance
次の記事Money-Saving Tips
コンピューティングレンタルに関するドキュメントガイドに戻る