Update discourse hostname

(James Smith) #1

I’m running w/ Docker on Ubuntu on Digital Ocean. I have tried updating the hostname in the app.yml file then doing a launcher rebuild, but it doesn’t change anything. I also tried manually navigating into the directory of the docker container and updating discourse.conf to have the correct hostname and not my IP address, but emails still get sent out with the IP address. What am I missing?

(Sam Saffron) #2

What do you mean … have you pointed the old DNS entry ad /dev/null and the new one at your current discourse ip ?

If the setting did not take you would see incorrect domains in emails, but nothing really on front page hit.

(James Smith) #3

Sorry I wasn’t particularly detailed in my post. The only problem I’m experiencing is the emails sending my current IP address rather than my domain name. I originally entered just my IP address as the host name when setting up the application, as my DNS wasn’t configured yet (I have to get someone else to do that for me as I don’t have access) and everything works, but despite what I’ve done I can’t get the emails to have my domain name rather than just my IP address.

(Jeff Atwood) #4

So edit the discourse hostname setting as specified in the install guide, then rebuild the container. Using an IP address as your Discourse name isn’t a good idea; you can access the server via the IP address regardless.

(James Smith) #5

Yeah that was my stupid mistake, I was just in a hurry and not thinking things through. For whatever reason, updating the hostname setting and rebuilding the container didn’t change what got sent out in the emails, but then I found and tried using force hostname in site_settings.yml and it works fine now.

(Jeff Atwood) #6

Force hostname is a developer setting, you should not be using that. You should fix your install.

(Roman M) #7

Similar issue here. Initially I ran discourse with a test hostname. When the new name registered I did the following on the same machine:

  • in OLD /var/discourse ./launcher stop app
  • mv /var/discourse/ /var/BACKUP/
  • mkdir /var/discourse <=== !!! create the whole thing from scratch
  • git clone “discourse_url” /var/discourse
  • cd /var/discourse
  • edited containers/app.yml with the new data, including new DISCOURSE_HOSTNAME
  • ./launcher bootstrap app
  • ./launcher start app

All is fine but as James says emails are coming from the test domain (IP in his case). Activate account link in the first email points to the OLD test domain. Activation worked but old domain must go! Did some grepping, found old domain name in the following files in the NEW directory /var/discourse:


It must be redis / ruby / rails / docker who remembers the old test hostname!

Any advice?

(Roman M) #8

I found my test domain in /var/lib/docker/devicemapper/devicemapper/data on the host. Looking how to clean docker data. The second installation must have reused some docker bits from the first installation.

(Roman M) #9

using “docker ps” and “docker images -a” found various docker bits. using “docker rm container_ID” and “docker rmi image_ID” - removed everything.
/var/lib/docker/devicemapper/devicemapper/data is still there and still has my old domain name in it…
Thinking what will be faster - install discourse again (with no old container and images), or redeploy the VM. :smile:

[root@mymachine /var/discourse]# ./launcher bootstrap app
which: no docker.io in (/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin)
Unable to find image 'samsaffron/discourse:1.0.6' locally
Pulling repository samsaffron/discourse

Aha! Got you!

(Roman M) #10

I can confirm that the old hostname persists through “./launcher rebuild app” and “./launcher bootstrap app” no matter what it set in containers/app.yml as DISCOURSE_HOSTNAME. Bug?

(Sam Stickland) #11

Same problem here…

I previously installed a server and entered it’s IP address as the hostname. After I got around to setting up a DNS entry I tried to change it the new hostname. It almost works. All the links in the emails etc are correct, but browsing to the server via it’s DNS name redirects to the IP address.The logo image also still links to the IP address (not the hostname).

I followed the instruction here Change the domain name or rename my Discourse? and did this:

  • Change hostname in app.yml and rebuilt server (./launcher rebuild app)
  • Changed all references in the admin panel from IP to hostname (I used a setting search with the IP addresss so I don’t believe I missed anything).
  • Remap and rebake

I haven’t yet started digging into the rails app or docker container.

(OG) #12

How can I change hostname in development environment? My upload urls are baked with localhost address…

[update] Seems like /config/discourse.conf only affects production…

(OG) #13

I’ve solved this by setting my domain in admin panel

force hostname
(DEVELOPER ONLY! WARNING! Specify a hostname in the URL. Leave blank for default.

and then running
rake posts:rebake

(Sara Rey Chipps) #14

I can’t get in the admin because I incorrectly setup the domain in the app.yml before building it (I used http://x.y.z instead of http://y.x.z). Should I just set up a new server? Updating the app.yml doesn’t fix where the emails come from.

(Jeff Atwood) #15

If you do a ./launcher rebuild the new name will take effect, but it requires a rebuild.

(Sara Rey Chipps) #16

Did a launcher rebuild, everything looks great (here is the output)

+ /usr/bin/docker run -d --restart=always -e LANG=en_US.UTF-8 -e RAILS_ENV=production -e UNICORN_WORKERS=3 -e UNICORN_SIDEKIQS=1 -e RUBY_GLOBAL_METHOD_CACHE_SIZE=131072 -e DISCOURSE_DB_SOCKET=/var/run/postgresql -e DISCOURSE_DB_HOST= -e DISCOURSE_DB_PORT= -e DISCOURSE_HOSTNAME=staging.discourse.jewelbots.com -e 'DISCOURSE_DEVELOPER_EMAILS=sara@jewelbots.com, philipapbak@gmail.com' -e DISCOURSE_SMTP_ADDRESS=smtp.mandrillapp.com -e DISCOURSE_SMTP_PORT=587 -e DISCOURSE_SMTP_USER_NAME=Jewelbots -e DISCOURSE_SMTP_PASSWORD=oops -e DISCOURSE_SMTP_ENABLE_START_TLS=true -h staging-app -e DOCKER_HOST_IP= --name app -t -p 80:80 -p 443:443 -v /var/discourse/shared/standalone:/shared -v /var/discourse/shared/standalone/log/var-log:/var/log --mac-address 02:ae:82:3d:cd:ea local_discourse/app /sbin/boot

However, the email still comes from http://staging.jewelbots.discourse.com :frowning:

(Jeff Atwood) #17

I don’t think the app.yml was updated correctly, because the above says DISCOURSE_HOSTNAME=staging.discourse.jewelbots.com

What does it look like when you edit the app.yml file?

(Sara Rey Chipps) #18

It looks like this:

## TODO: The domain name this Discourse instance will respond to
DISCOURSE_HOSTNAME: 'staging.discourse.jewelbots.com'

That IS the correct URL.

The incorrect URL is staging.jewelbots.discourse.com which is where the emails are still coming from.

(Jeff Atwood) #19

If the ./launcher rebuild is complete, I can’t think of any reason the old site URL would still be hanging around.

Did you search Admin, Site Settings to see if the old URL form is in any of your site settings?

(Sara Rey Chipps) #20

I can’t get into the admin as the admin has never registered, it’s a new instance. I restarted the server to see if the change was made and no dice.

I’m guessing the best thing to do is nuke this instance and start another?