Skip to content

Commit

Permalink
add extra information regarding certificates
Browse files Browse the repository at this point in the history
  • Loading branch information
Mick Vermeulen authored and Mick Vermeulen committed Sep 16, 2020
1 parent ed6fdf0 commit 6489675
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 29 deletions.
29 changes: 17 additions & 12 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
# Configuration file for Uchu Docker
DATABASE_PORT=5432
REDIS_PORT=6379
ADMINER_PORT=8080
DATA_FOLDER=./data
# Only this variable has to be changed
GAME_FOLDER=/res

# Postgres specific setup
# No modifications needed by default
DATA_FOLDER=./data
CERTIFICATE=./cert.pfx

# Postgres specific setup, no modifications needed by default
POSTGRES_USER=uchu
POSTGRES_PASSWORD=uchu
POSTGRES_DB=uchu

# Uchu specific setup
CHARACTER_PORT=2002
API_PORT=10000
MAX_WORLD_SERVERS=100
# Should be API_PORT + MAX_WORLD_SERVERS
MAX_API_PORT=10100
# Exposed Uchu specific setup, no modifications needed by default
DATABASE_PORT=5432
REDIS_PORT=6379
ADMINER_PORT=8080
UCHU_HANDSHAKE_PORT=1001
UCHU_CHARACTER_PORT=2002
UCHU_CHAT_PORT=2004
UCHU_API_PORT_RANGE=10000-10100
UCHU_WORLD_PORT_RANGE=20000-20100
UCHU_SERVER_PORT=21836
UCHU_AUTH_PORT=40000
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,16 @@ This allows you to input shell commands like `/adduser <username>`. You can exit
docker-compose down
```

## Applying changes to .env

When applying any changes to the `.env` file after your initial `docker-compose up -d`, the changes aren't built into the container. First run `docker-compose build --no-cache` to apply your `.env` file changes after which `docker-compose up -d` can be used again to start up Uchu. Note that this is not required if you only changed the LU resource location before running your first `docker-compose up -d`, but is required for any subsequent changes.

## Adminer

Uchu Docker also automatically runs [Adminer](https://www.adminer.org), which allows you to easily modify the Uchu database in a user friendly way. After running Uchu Docker you can access Adminer through your browser at 0.0.0.0:8080 (or at 0.0.0.0:$ADMINER_PORT if you changed this in the `.env` file). Select the `PostgreSQL` database type, set the server to `db` and enter the credentials found in the `.env` file to login. More info on how to use Adminer can be found on their website.
Uchu Docker also automatically runs [Adminer](https://www.adminer.org), which allows you to easily modify the Uchu database in a user friendly way. After running Uchu Docker you can access Adminer through your browser at 0.0.0.0:8080. Select the `PostgreSQL` database type, set the server to `db` and enter the credentials found in the `.env` file to login. More info on how to use Adminer can be found on their website.

## Hosting (Advanced)

## World ports (Advanced)
This Docker setup can be used to host Uchu as long as all ports are exposed (see the .env.sample file for all ports that need to be exposed). Do note that hosting Uchu on anything other than `localhost` requires a valid PFX certificate from a trusted CA like Let's Encrypt and therefore also a valid domain name. You *cannot* use a self signed certificate even if you first generate your own root certificate, as the TcpUdp mod does not look at the OS certificate store for valid root certificates. You can specify the path to your PFX certificate using the `$CERTIFICATE` environment variable.

If you wish to change the world ports, you can change the exposed ports in the `.env` file easily. The internal ports are locked by default to `2002` for the charater port and `10000-10100` for the api and world ports. If you wish to change these internal ports update the internal port values in the `.env` file. Ensure that `INTERNAL_API_PORT_RANGE` is updated to match your updated `INTERNAL_API_PORT` and `INTERNAL_MAX_WORLDS`.
When hosting Uchu on a private network, for example in a LAN scenario, it might be a bit cumbersome to get a valid certficate and a domain. An alternative solution would be to run Uchu on a host device, find it's private network IP using `ipconfig` or `ifconfig` and port-forwarding all Uchu ports on `localhost` on client machines to the private network IP and the respective ports. This way clients on the private network can connect with Uchu through `localhost` and therefore no certificate is required. To ensure this works port-forward all the ports from the `.env` file on all client machines to the host machine.
2 changes: 1 addition & 1 deletion Uchu
Submodule Uchu updated from 837e20 to 33fc2f
3 changes: 2 additions & 1 deletion Uchu.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
FROM mcr.microsoft.com/dotnet/core/sdk:3.1-alpine
COPY Uchu config.default.xml .env ./

RUN apk add gettext
RUN apk update && apk add --no-cache gettext && apk add --no-cache openssl

RUN set -o allexport && source .env && set +o allexport && envsubst < config.default.xml > config.xml
RUN dotnet build

Expand Down
14 changes: 7 additions & 7 deletions config.default.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,20 @@
</FileLogging>
<DllSource>
<DotNetPath>dotnet</DotNetPath>
<Instance>./Uchu.Instance/bin/Debug/netcoreapp3.1/Uchu.Instance.dll</Instance>
<ScriptDllSource>./Uchu.StandardScripts/bin/Debug/netcoreapp3.1/Uchu.StandardScripts.dll</ScriptDllSource>
<Instance>Uchu.Instance/bin/Debug/netcoreapp3.1/Uchu.Instance.dll</Instance>
<ScriptDllSource>Uchu.StandardScripts</ScriptDllSource>
</DllSource>
<ManagedScriptSources />
<ResourcesConfiguration>
<GameResourceFolder>/res</GameResourceFolder>
</ResourcesConfiguration>
<Networking>
<Certificate />
<Hostname />
<CharacterPort>$INTERNAL_CHARACTER_PORT</CharacterPort>
<Certificate>$CERTIFICATE</Certificate>
<Hostname>localhost</Hostname>
<CharacterPort>2002</CharacterPort>
<HostAuthentication>true</HostAuthentication>
<HostCharacter>true</HostCharacter>
<MaxWorldServers>$INTERNAL_MAX_WORLDS</MaxWorldServers>
<MaxWorldServers>100</MaxWorldServers>
</Networking>
<GamePlay>
<PathFinding>false</PathFinding>
Expand All @@ -40,7 +40,7 @@
<Api>
<Protocol>http</Protocol>
<Domain>localhost</Domain>
<Port>$INTERNAL_API_PORT</Port>
<Port>10000</Port>
</Api>
<Cache>
<Host>redis</Host>
Expand Down
15 changes: 10 additions & 5 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ services:
- .env
restart: always
ports:
- "${DATABASE_PORT}:5432"
- ${DATABASE_PORT}:5432
volumes:
- ${DATA_FOLDER}:/var/lib/postgresql/data
adminer:
Expand All @@ -15,14 +15,14 @@ services:
depends_on:
- db
ports:
- "${ADMINER_PORT}:8080"
- ${ADMINER_PORT}:8080
redis:
image: redis:6.0.8-alpine
env_file:
- .env
restart: always
ports:
- "${REDIS_PORT}:6379"
- ${REDIS_PORT}:6379
volumes:
- ${DATA_FOLDER}:/data
uchu:
Expand All @@ -37,7 +37,12 @@ services:
volumes:
- ${GAME_FOLDER}:/res
ports:
- "${CHARACTER_PORT}:${INTERNAL_CHARACTER_PORT}"
- "${API_PORT_RANGE}:${INTERNAL_API_PORT_RANGE}"
- ${UCHU_HANDSHAKE_PORT}:1001
- ${UCHU_CHARACTER_PORT}:2002
- ${UCHU_CHAT_PORT}:2004
- ${UCHU_API_PORT_RANGE}:10000-10100
- ${UCHU_WORLD_PORT_RANGE}:20000-20100
- ${UCHU_SERVER_PORT}:21836
- ${UCHU_AUTH_PORT}:40000
tty: true
stdin_open: true

0 comments on commit 6489675

Please sign in to comment.