Add an IP bind param to the entrypoint (#447)

* Add an IP bind param to the entrypoint

* Add an example usage to readme

* Rename to BIND
This commit is contained in:
Adam Zahumenský 2022-09-05 11:01:06 +02:00 committed by GitHub
parent 2f28ee6626
commit 5aef1b9f6f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 0 deletions

View File

@ -262,6 +262,7 @@ These are the environment variables which can be specified at container run time
| GENERATE_NEW_SAVE | Generate a new save if one does not exist before starting the server | false | 0.17+ |
| LOAD_LATEST_SAVE | Load latest when true. Otherwise load SAVE_NAME | true | 0.17+ |
| PORT | UDP port the server listens on | 34197 | 0.15+ |
| BIND | IP address (v4 or v6) the server listens on (IP\[:PORT]) | | 0.15+ |
| RCON_PORT | TCP port the rcon server listens on | 27015 | 0.15+ |
| SAVE_NAME | Name to use for the save file | _autosave1 | 0.17+ |
| TOKEN | factorio.com token | | 0.17+ |
@ -383,6 +384,21 @@ For LAN games the VM needs an internal IP in order for clients to connect. One w
If you're looking for a simple way to deploy this to the Amazon Web Services Cloud, check out the [Factorio Server Deployment (CloudFormation) repository](https://github.com/m-chandler/factorio-spot-pricing). This repository contains a CloudFormation template that will get you up and running in AWS in a matter of minutes. Optionally it uses Spot Pricing so the server is very cheap, and you can easily turn it off when not in use.
## Using a reverse proxy
If you need to use a reverse proxy you can use the following nginx snippet:
```
stream {
server {
listen 34197 udp reuseport;
proxy_pass my.upstream.host:34197;
}
}
```
If your factorio host uses multiple IP addresses (very common with IPv6), you might additionally need to bind Factorio to a single IP (otherwise the UDP proxy might get confused with IP mismatches). To do that pass the `BIND` envvar to the container: `docker run --network=host -e BIND=2a02:1234::5678 ...`
## Troubleshooting
### My server is listed in the server browser, but nobody can connect

View File

@ -20,3 +20,4 @@ services:
# - USERNAME=FactorioUsername
# - TOKEN=FactorioToken
# - PORT=34198
# - ADDR=::1

View File

@ -5,6 +5,7 @@ FACTORIO_VOL=/factorio
LOAD_LATEST_SAVE="${LOAD_LATEST_SAVE:-true}"
GENERATE_NEW_SAVE="${GENERATE_NEW_SAVE:-false}"
SAVE_NAME="${SAVE_NAME:-""}"
BIND="${BIND:-""}"
mkdir -p "$FACTORIO_VOL"
mkdir -p "$SAVES"
@ -88,6 +89,10 @@ FLAGS=(\
--server-id /factorio/config/server-id.json \
)
if [ -n "$BIND" ]; then
FLAGS+=( --bind "$BIND" )
fi
if [[ $LOAD_LATEST_SAVE == true ]]; then
FLAGS+=( --start-server-load-latest )
else