Hi everyone! I always wanted to try to host my own Forem instance and I had a project in mind that could perfectly fit the use case for Forem.
I own a domain from OVH.com, vivredart.com. I use their DNS servers.
I followed the guide to selfhost on DigitalOcean with Mac OS. Everything works fine except for traefik that I am not able to configure as I want.
By default the subdomain in the config files is set to www (ie. www.vivredart.com). I'd like to force redirect all www request to vivredart.com and also to get ride of the subdomain.
I tried to put @, '' or simply deleting it. Everytime it fails to execute. There is no documentation regarding this point but I've see dev.to and forem.dev not using www so I guess it is possible.
I also tried to edit the deployed traefik dynamic.toml and traefik.toml files without success.
Below is my setup.yml with my current settings.
---
all:
hosts:
vars:
ssh_key: "{{ lookup('file', '~/.ssh/forem.pub') }}"
app_protocol: https://
database_pool_size: 10
force_ssl_in_rails: "true"
lang: en_US.UTF-8
node_env: "{{ forem_environment }}"
rack_env: "{{ forem_environment }}"
rack_timeout_service_timeout: 300
rack_timeout_wait_timeout: 300
rails_env: "{{ forem_environment }}"
rails_log_to_stdout: "true"
rails_serve_static_files: enabled
redis_sessions_url: redis://localhost:6379
redis_sidekiq_url: redis://localhost:6379
redis_url: redis://localhost:6379
session_expiry_seconds: 1209600
web_concurrency: 2
forem_context: selfhost
forem_container_tag: quay.io/forem/forem:latest
children:
forems:
hosts:
forem:
ansible_connection: local
ansible_python_interpreter: /usr/bin/python3 # on macOS, this may need to be /usr/local/bin/python3
# CHANGE_REQUIRED — forem_domain_name: example.com
forem_domain_name: vivredart.com
# CHANGE_REQUIRED — default_email: your_email@example.com
default_email: ...
forem_subdomain_name: www # can be subdomain, i.e. "community" in community.mainwebsite.com
forem_server_hostname: host # You may change to something else if you choose (i.e. server, srv, etc)
# CHANGE_OPTIONAL - strict-origin-when-cross-origin enables embedded youtube video playback
# referrer_policy: "same-origin"
referrer_policy: "strict-origin-when-cross-origin"
app_domain: "{{ forem_subdomain_name }}.{{ forem_domain_name }}"
secret_key_base: "{{ vault_secret_key_base }}"
session_key: _FOREMSELFHOST_Session
imgproxy_key: "{{ vault_imgproxy_key }}"
imgproxy_salt: "{{ vault_imgproxy_salt }}"
forem_version: latest
forem_environment: production
dd_api_key: "{{ vault_dd_api_key }}"
honeybadger_api_key: "{{ vault_honeybadger_api_key }}"
honeybadger_js_api_key: "{{ vault_honeybadger_js_api_key }}"
honeycomb_api_key: "{{ vault_honeycomb_api_key }}"
postgres_user: forem_production
postgres_password: "{{ vault_forem_postgres_password }}"
postgres_host: localhost
recaptcha_secret: "{{ vault_recaptcha_secret }}"
recaptcha_site: "{{ vault_recaptcha_site }}"
sendgrid_api_key: "{{ vault_sendgrid_api_key }}"
sendgrid_api_key_id: "{{ vault_sendgrid_api_key_id }}"
slack_channel: "#forem-activity"
slack_webhook_url: "{{ vault_slack_webhook_url }}"
# Required Ansible Vault secret variables
# Use the following example commands below in a terminal to generate the required variables with Ansible Vault encrypt_string
# These commands should be run in the selfhost directory, since the
# ansible.cfg identifies the vault password which will be used to decrypt
# if ansible-vault prompts for a password, something is not right
# See this URL to learn more about ansible-vault:
# https://docs.ansible.com/ansible/latest/user_guide/vault.html#encrypting-individual-variables-with-ansible-vault
...
Thank you really much for your help and for your involvement in the Forem community.
Top comments (1)
Hi again,
After some tinkering, I managed to deploy without a subdomain. The www to non-www redirection does not work out of the box but I tried to add a CNAME DNS Zone to redirect vivredart.com to vivredart.com. It should propagate soon.
In the mean time, here is what I changed in my setup.yml file (I only put what I changed).
Because I use OVH's dns, I commented the networking steps that were creating a
zone and A fields into the digitalocean.yml config file.
I hope this can help in the future.