Skip to content

Commit

Permalink
doc: add rg port ranges to self hosting docs
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanFlurry committed Dec 10, 2024
1 parent 63b840d commit 91896a2
Show file tree
Hide file tree
Showing 18 changed files with 111 additions and 38 deletions.
14 changes: 10 additions & 4 deletions docs/src/content/docs/networking.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,7 @@ If using host ports, read about differences in behavior with [actor rescheduling

### Host

<Note>
"Host endpoint type" has no association with "host networking" or "host
routing" above.
</Note>
<Note>"Host endpoint type" has no association with "host networking" or "host routing" above.</Note>

The host endpoint type uses the `Host` header to route the request to the correct actor. This is the default & recommended method to use for production Rivet clusters.

Expand All @@ -98,6 +95,15 @@ The path endpoint type uses the beginning of the request path to route to the co
- Self hosting or developing Rivet without a wildcard DNS record (e.g. Rivet Guard running on `127.0.0.1:7080`)
- Rare cases where explicit hostnames need to be whitelisted (e.g. Discord Activities [URL mappings](https://discord.com/developers/docs/activities/development-guides#url-mapping))

<Warning>
Directing your users to an HTML page with path endpoint type may be a security
risk. The origin for path endpoint types (`route.actor.{region}.rivet.run`) is
shared with other actors. This means that all cookies, local/session storage,
web workers, etc are shared with any other actor running in the same region.

Use the host endpoint type instead if serving HTML content.
</Warning>

## Routing Diagram

This diagram shows how requests are routed from the end-user to the application running on Rivet based on the
Expand Down
12 changes: 9 additions & 3 deletions docs/src/content/docs/self-hosting/docker-compose.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,21 @@ This Docker Compose is intended for running a full development environment for R

## Prerequisites

- Docker
- Docker Compose

## Required ports

The following ports need to be open before running Rivet:

- 8080-8082 (Rivet server)
- 9000 (S3)
- 20000-20100 (Rivet client host networking)
| Service | Description | Optional | Port |
| ------------ | --------------- | -------- | --------- |
| Rivet Server | API | | 8080 |
| | Object Storage | | 9000 |
| Rivet Guard | HTTP | | 7080 |
| | HTTPS | | 7443 |
| | TCP & UDP | X | 7500-7599 |
| Rivet Client | Host Networking | X | 7600-7699 |

## Operation

Expand Down
12 changes: 10 additions & 2 deletions packages/api/provision/src/route/servers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,20 @@ pub async fn info(
server.server_id,
)?;

let lan_ip = unwrap_ref!(server.lan_ip, "server should have lan hostname by now").to_string();
let wan_ip =
unwrap_ref!(server.wan_ip, "server should have public hostname by now").to_string();

Ok(models::ProvisionServersGetInfoResponse {
name,
server_id: server.server_id,
datacenter_id: server.datacenter_id,
cluster_id: datacenter.cluster_id,
lan_ip: unwrap_ref!(server.lan_ip, "server should have lan hostname by now").to_string(),
wan_ip: unwrap_ref!(server.wan_ip, "server should have public hostname by now").to_string(),
lan_ip: lan_ip.clone(),
wan_ip: wan_ip.clone(),

// Deprecated
vlan_ip: lan_ip,
public_ip: wan_ip,
})
}
5 changes: 1 addition & 4 deletions packages/services/cluster/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,10 +218,7 @@ impl GuardPublicHostname {
let hostname = format!("actor.{}.{domain_job}", datacenter_id);
crate::types::GuardPublicHostname::DnsParent(hostname)
} else {
tracing::warn!(?datacenter_id, "no guard public hostname specified");
crate::types::GuardPublicHostname::Static(
"no-guard-public-hostname-specified-in-config.invalid".into(),
)
bail!("no guard public hostname specified in dc {datacenter_id}")
}
}
};
Expand Down
18 changes: 10 additions & 8 deletions packages/services/cluster/src/workflows/datacenter/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,16 @@ pub(crate) async fn cluster_datacenter(ctx: &mut WorkflowCtx, input: &Input) ->
};

// TODO(RVT-4340): Clean up this syntax
if ctx.is_new().await? {
ctx.activity(InsertDbInputV2 {
v1,
guard_public_hostname: input.guard_public_hostname.clone(),
})
.await?;
} else {
ctx.activity(v1).await?;
match ctx.check_version(2).await? {
1 => ctx.activity(v1).await?,
2 => {
ctx.activity(InsertDbInputV2 {
v1,
guard_public_hostname: input.guard_public_hostname.clone(),
})
.await?
}
_ => bail!("unreachable"),
}
}

Expand Down
14 changes: 7 additions & 7 deletions packages/services/ds/src/workflows/server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,6 @@ pub struct Port {

#[workflow]
pub async fn ds_server(ctx: &mut WorkflowCtx, input: &Input) -> GlobalResult<()> {
let network_ports = ctx
.activity(DisableTlsPortsInput {
network_ports: input.network_ports.as_hashable(),
})
.await?;

let validation_res = ctx
.activity(ValidateInput {
env_id: input.env_id,
Expand All @@ -71,7 +65,7 @@ pub async fn ds_server(ctx: &mut WorkflowCtx, input: &Input) -> GlobalResult<()>
args: input.args.clone(),
network_mode: input.network_mode,
environment: input.environment.as_hashable(),
network_ports: network_ports.clone(),
network_ports: input.network_ports.as_hashable(),
})
.await?;

Expand All @@ -87,6 +81,12 @@ pub async fn ds_server(ctx: &mut WorkflowCtx, input: &Input) -> GlobalResult<()>
return Ok(());
}

let network_ports = ctx
.activity(DisableTlsPortsInput {
network_ports: input.network_ports.as_hashable(),
})
.await?;

match input.runtime {
ServerRuntime::Nomad => {
ctx.workflow(nomad::Input {
Expand Down
15 changes: 13 additions & 2 deletions scripts/openapi/gen_rust.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ async function generateRustSdk() {
}

async function fixOpenApiBugs() {
const files = {
const files: Record<string, [RegExp, string][]> = {
"cloud_games_matchmaker_api.rs": [
[/CloudGamesLogStream/g, "crate::models::CloudGamesLogStream"],
],
Expand All @@ -80,7 +80,18 @@ async function fixOpenApiBugs() {

for (const [file, replacements] of Object.entries(files)) {
const filePath = `${GEN_PATH_RUST}/src/apis/${file}`;
let content = await Deno.readTextFile(filePath);
let content;
try {
content = await Deno.readTextFile(filePath);
} catch (error) {
if (error instanceof Deno.errors.NotFound) {
console.warn(`File not found: ${filePath}`);
continue;
} else {
throw error;
}
}

for (const [from, to] of replacements) {
content = content.replace(from, to);
}
Expand Down
10 changes: 10 additions & 0 deletions sdks/api/fern/definition/provision/servers/__package__.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,13 @@ types:
cluster_id: uuid
lan_ip: string
wan_ip: string
vlan_ip:
availability: deprecated
docs: >-
**Deprecated**: Use lan_ip
type: string
public_ip:
availability: deprecated
docs: >-
**Deprecated**: Use wan_ip
type: string
4 changes: 4 additions & 0 deletions sdks/api/full/go/provision/servers/servers.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions sdks/api/full/openapi/openapi.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions sdks/api/full/openapi_compat/openapi.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions sdks/api/full/rust/docs/ProvisionServersGetInfoResponse.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions sdks/api/full/typescript/archive.tgz

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions sdks/api/runtime/rust/Cargo.toml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions sdks/api/runtime/rust/src/apis/actor_api.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion sdks/api/runtime/rust/src/apis/actor_logs_api.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions sdks/api/runtime/typescript/archive.tgz

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 91896a2

Please sign in to comment.