|
| 1 | +# SSL Certificate with Certbot |
| 2 | + |
| 3 | +The instructions below will help you to deploy a signed SSL certificate for your Satisfactory server. |
| 4 | + |
| 5 | +## Docker Compose |
| 6 | + |
| 7 | +```yaml |
| 8 | +services: |
| 9 | + satisfactory-server: |
| 10 | + container_name: 'satisfactory-server' |
| 11 | + hostname: 'satisfactory-server' |
| 12 | + image: 'wolveix/satisfactory-server:latest' |
| 13 | + ports: |
| 14 | + - '7777:7777/udp' |
| 15 | + - '7777:7777/tcp' |
| 16 | + volumes: |
| 17 | + - './satisfactory-server:/config' |
| 18 | + - './certs/live/${DOMAIN}/fullchain.pem:/config/gamefiles/FactoryGame/Certificates/cert_chain.pem' |
| 19 | + - './certs/live/${DOMAIN}/privkey.pem:/config/gamefiles/FactoryGame/Certificates/private_key.pem' |
| 20 | + environment: |
| 21 | + - MAXPLAYERS=4 |
| 22 | + - PGID=1000 |
| 23 | + - PUID=1000 |
| 24 | + - ROOTLESS=false |
| 25 | + - STEAMBETA=false |
| 26 | + restart: unless-stopped |
| 27 | + depends_on: |
| 28 | + certbot: |
| 29 | + condition: service_completed_successfully |
| 30 | + healthcheck: |
| 31 | + test: bash /healthcheck.sh |
| 32 | + interval: 30s |
| 33 | + timeout: 10s |
| 34 | + retries: 3 |
| 35 | + start_period: 120s |
| 36 | + deploy: |
| 37 | + resources: |
| 38 | + limits: |
| 39 | + memory: 6G |
| 40 | + reservations: |
| 41 | + memory: 4G |
| 42 | + |
| 43 | + certbot: |
| 44 | + image: certbot/certbot |
| 45 | + command: certonly --standalone --non-interactive --agree-tos -m ${CERTBOT_MAIL} -d ${DOMAIN} |
| 46 | + ports: |
| 47 | + - '80:80/tcp' |
| 48 | + volumes: |
| 49 | + - ./certs:/etc/letsencrypt |
| 50 | + environment: |
| 51 | + - CERTBOT_MAIL=certbot@domain.tld |
| 52 | + - DOMAIN=satisfactory.domain.tld |
| 53 | +``` |
| 54 | +
|
| 55 | +The `docker-compose.yml` file above should replace the `docker-compose.yml` file you already have configured. Adjust the |
| 56 | +`CERTBOT_MAIL` and `DOMAIN` environment variables under the `certbot` service to be a real email address, and the domain |
| 57 | +you'd like to issue the SSL certificate for. Ensure prior to running this that you've already created the necessary DNS |
| 58 | +record for your domain. If you don't certbot will fail, and you'll likely hit your rate limit and need to wait a while |
| 59 | +to try again (check the `certbot` container's logs for further information). |
| 60 | + |
| 61 | +**Ensure that you open/port forward for port `80/tcp`.** |
| 62 | + |
| 63 | +You can now launch the Docker Compose configuration in the same way you normally would. Do note that if Certbot fails, |
| 64 | +the game server will not start. |
| 65 | + |
| 66 | +## Troubleshooting |
| 67 | + |
| 68 | +### What if port 80 is already in-use with a reverse-proxy? |
| 69 | + |
| 70 | +Change the port for the certbot service (e.g. `7800:80/tcp`), and forward HTTP traffic from your reverse proxy through |
| 71 | +to your `certbot` container. |
| 72 | + |
| 73 | +Here are examples on how you can do this with Caddy and NGINX |
| 74 | + |
| 75 | +#### Caddy |
| 76 | + |
| 77 | +Modify your Caddyfile to include your given domain above. Ensure that you put `http://` **before** the domain, otherwise |
| 78 | +Caddy will _also_ request an SSL certificate for it. |
| 79 | + |
| 80 | +``` |
| 81 | +http://satisfactory.domain.tld { |
| 82 | + reverse_proxy :7780 |
| 83 | +} |
| 84 | +``` |
| 85 | +
|
| 86 | +
|
| 87 | +#### NGINX |
| 88 | +
|
| 89 | +Modify your NGINX configuration file to include the following virtual host: |
| 90 | +
|
| 91 | +``` |
| 92 | +server { |
| 93 | + listen 80; |
| 94 | + server_name satisfactory.domain.tld; |
| 95 | + |
| 96 | + location / { |
| 97 | + proxy_pass http://localhost:7780; |
| 98 | + } |
| 99 | +} |
| 100 | +``` |
0 commit comments