Cloudflare Tunnels - Discourse Setup Not Recognizing Hostname (Port not accessible)

I have the cloudflared daemon running properly and have used it for tons of stuff(meaning the tunnel is installed properly on the server), but I am having trouble getting the Discourse setup(./discourse-setup) to recognize my hostname for my Discourse instance.

  • I am using biohacking.forum as the hostname for my instance.
  • This my my Cloudflare Tunnel configuration for biohacking.forum:
  • I have also tried setting it to HTTPS for the service type
  • I am setting up Discourse on an Ubuntu server, on LTS.
  • I ran the following commands in this order:
  1. sudo mkdir /var/discourse
  2. sudo git clone GitHub - discourse/discourse_docker: A Docker image for Discourse /var/discourse
  3. cd /var/discourse
  4. sudo ./discourse-setup
  5. It prompts me for the hostname, I enter biohacking.forum
  6. The following message is displayed:
Hostname for your Discourse? [discourse.example.com]: biohacking.forum

Checking your domain name . . .
WARNING: Port 443 of computer does not appear to be accessible using hostname:  biohacking.forum.
WARNING: Connection to http://biohacking.forum (port 80) also fails.

This suggests that biohacking.forum resolves to some IP address that does not reach this 
machine where you are installing discourse.

The first thing to do is confirm that biohacking.forum resolves to the IP address of this server.
You usually do this at the same place you purchased the domain.

If you are sure that the IP address resolves correctly, it could be a firewall issue.
A web search for "open ports YOUR CLOUD SERVICE" might help.

This tool is designed only for the most standard installations. If you cannot resolve
the issue above, you will need to edit containers/app.yml yourself and then type

./launcher rebuild app

What should I do to get this step working, please let me know if you need any addtl. information. Thank you!

Hey, do you have the grey cloud (dns only) for the “A” record before the ./discourse-setup?

I am not using a standard A record, I am using cloudflare tunnels. Here an example of a service that works perfectly on my server(with cloudflare tunnels) and the associated config:

Ghost CMS is the service:
PORT: 8085:2368 (8085 is host and 2368 is service)
HOSTNAME: joshuahabka.com
Cloudflare Tunnel Setup:

The orange cloudflare icon is on since it uses Cloudflare tunnels but to Discourse it should report as a normal access port… I have over 40 services deployed and web-accessible and Discourse is the first where I am having some error with it.

Please let me know if you need addtl. info!

So for Discourse I would assume the port is:
443:443 (host:service) which is why I had my original Cloudflare tunnel setup as shown above

Hi @joshhabka :wave:
perhaps this topic will help, if you haven’t already seen it

4 Likes

Hi Lilly, the aforementioned guide did not work for me, I still receive the same error even though my cloudflare tunnel configuration is http://localhost:80 as stated I am still stuck on

starserver@Starserver:/var/discourse$ sudo ./discourse-setup 
Ports 80 and 443 are free for use
'samples/standalone.yml' -> 'containers/app.yml'
./discourse-setup: line 261: 4
scaling*                 2: syntax error in expression (error token is "scaling*                 2")

Hostname for your Discourse? [discourse.example.com]: biohacking.forum

Checking your domain name . . .
WARNING: Port 443 of computer does not appear to be accessible using hostname:  biohacking.forum.
WARNING: Connection to http://biohacking.forum (port 80) also fails.

This suggests that biohacking.forum resolves to some IP address that does not reach this 
machine where you are installing discourse.

The first thing to do is confirm that biohacking.forum resolves to the IP address of this server.
You usually do this at the same place you purchased the domain.

If you are sure that the IP address resolves correctly, it could be a firewall issue.
A web search for "open ports YOUR CLOUD SERVICE" might help.

This tool is designed only for the most standard installations. If you cannot resolve
the issue above, you will need to edit containers/app.yml yourself and then type

./launcher rebuild app

Turning off " Always Use HTTPS

Redirect all requests with scheme “http” to “https”. This applies to all http requests to the zone." makes it so port 80 succeeds but not 443

Enabling a page rule to redirect to HTTPS also causes both 80 and 443 to fail, but if I dont use it then 443 fails and 80 succeeds.

You’re not following the instructions.

You can’t use discourse-setup except to have it create the yml file.

1 Like

Thank you, I am now stuck here:

FAILED
--------------------
Pups::ExecError: /usr/local/bin/ruby -e 'if ENV["DISCOURSE_SMTP_ADDRESS"] == "smtp.example.com"; puts "Aborting! Mail is not configured!"; exit 1; end' failed with return #<Process::Status: pid 134 exit 1>
Location of failure: /usr/local/lib/ruby/gems/3.3.0/gems/pups-1.2.1/lib/pups/exec_command.rb:132:in `spawn'
exec failed with the params {"tag"=>"precompile", "cmd"=>["/usr/local/bin/ruby -e 'if ENV[\"DISCOURSE_SMTP_ADDRESS\"] == \"smtp.example.com\"; puts \"Aborting! Mail is not configured!\"; exit 1; end'", "/usr/local/bin/ruby -e 'if ENV[\"DISCOURSE_HOSTNAME\"] == \"discourse.example.com\"; puts \"Aborting! Domain is not configured!\"; exit 1; end'", "/usr/local/bin/ruby -e 'if (ENV[\"DISCOURSE_CDN_URL\"] || \"\")[0..1] == \"//\"; puts \"Aborting! CDN must have a protocol specified. Once fixed you should rebake your posts now to correct all posts.\"; exit 1; end'"]}
bootstrap failed with exit code 1
** FAILED TO BOOTSTRAP ** please scroll up and look for earlier error messages, there may be more than one.
./discourse-doctor may help diagnose the problem.

You have to edit the yml file and enter smtp credentials

Completed that and all is nominal now. I would just put a note in the self-install for cloudflare tunnel post that people need to edit the yaml doc to add their smtp, hostname, emails, etc

Thank you!