domain

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Domain Management

域名管理

Add, view, or remove domains for Railway services.
为Railway服务添加、查看或删除域名。

When to Use

使用场景

  • User asks to "add a domain", "generate a domain", "get a URL"
  • User wants to add a custom domain
  • User asks "what's the URL for my service"
  • User wants to remove a domain
  • 用户要求“添加域名”、“生成域名”、“获取URL”
  • 用户想要添加自定义域名
  • 用户询问“我的服务URL是什么”
  • 用户想要删除域名

Add Railway Domain

添加Railway域名

Generate a railway-provided domain (max 1 per service):
bash
railway domain --json
For a specific service:
bash
railway domain --json --service backend
生成Railway提供的域名(每个服务最多1个):
bash
railway domain --json
针对特定服务:
bash
railway domain --json --service backend

Response

返回结果

Returns the generated domain URL. Service must have a deployment.
返回生成的域名URL。服务必须已部署。

Add Custom Domain

添加自定义域名

bash
railway domain example.com --json
bash
railway domain example.com --json

Response

返回结果

Returns required DNS records:
json
{
  "domain": "example.com",
  "dnsRecords": [
    { "type": "CNAME", "host": "@", "value": "..." }
  ]
}
Tell user to add these records to their DNS provider.
返回所需的DNS记录:
json
{
  "domain": "example.com",
  "dnsRecords": [
    { "type": "CNAME", "host": "@", "value": "..." }
  ]
}
告知用户需将这些记录添加到其DNS服务商处。

Read Current Domains

查看当前域名

Use
environment
skill to see configured domains, or query directly:
graphql
query domains($envId: String!) {
  environment(id: $envId) {
    config(decryptVariables: false)
  }
}
Domains are in
config.services.<serviceId>.networking
:
  • serviceDomains
    - Railway-provided domains
  • customDomains
    - User-provided domains
使用
environment
Skill查看已配置的域名,或直接查询:
graphql
query domains($envId: String!) {
  environment(id: $envId) {
    config(decryptVariables: false)
  }
}
域名位于
config.services.<serviceId>.networking
中:
  • serviceDomains
    - Railway提供的域名
  • customDomains
    - 用户提供的自定义域名

Remove Domain

删除域名

Use
environment
skill to remove domains:
使用
environment
Skill删除域名:

Remove custom domain

删除自定义域名

json
{
  "services": {
    "<serviceId>": {
      "networking": {
        "customDomains": { "<domainId>": null }
      }
    }
  }
}
json
{
  "services": {
    "<serviceId>": {
      "networking": {
        "customDomains": { "<domainId>": null }
      }
    }
  }
}

Remove railway domain

删除Railway域名

json
{
  "services": {
    "<serviceId>": {
      "networking": {
        "serviceDomains": { "<domainId>": null }
      }
    }
  }
}
Then use
environment
skill to apply and commit the change.
json
{
  "services": {
    "<serviceId>": {
      "networking": {
        "serviceDomains": { "<domainId>": null }
      }
    }
  }
}
然后使用
environment
Skill应用并提交更改。

CLI Options

CLI选项

FlagDescription
[DOMAIN]
Custom domain to add (omit for railway domain)
-p, --port <PORT>
Port to connect
-s, --service <NAME>
Target service (defaults to linked)
--json
JSON output
参数描述
[DOMAIN]
要添加的自定义域名(省略则生成Railway域名)
-p, --port <PORT>
要连接的端口
-s, --service <NAME>
目标服务(默认使用已关联的服务)
--json
以JSON格式输出

Composability

可组合性

  • Read domains: Use
    environment
    skill
  • Remove domains: Use
    environment
    skill
  • Apply removal: Use
    environment
    skill
  • Check service: Use
    service
    skill
  • 查看域名:使用
    environment
    Skill
  • 删除域名:使用
    environment
    Skill
  • 应用删除操作:使用
    environment
    Skill
  • 检查服务:使用
    service
    Skill

Error Handling

错误处理

No Service Linked

未关联服务

No service linked. Use --service flag or run `railway service` to select one.
未关联服务。请使用--service参数或运行`railway service`选择一个服务。

Domain Already Exists

域名已存在

Service already has a railway-provided domain. Maximum 1 per service.
该服务已拥有一个Railway提供的域名。每个服务最多只能有1个。

No Deployment

无部署记录

Service has no deployment. Deploy first with `railway up`.
该服务无部署记录。请先使用`railway up`进行部署。

Invalid Domain

域名无效

Invalid domain format. Use a valid domain like "example.com" or "api.example.com".
域名格式无效。请使用有效的域名,例如"example.com"或"api.example.com"。