如何在开发模式下允许自定义主机

Hi.

I’m new to discourse and started diving into it by setting up a development system, following this howto.
Afterwards I was able to access my instance via ip address, but trying to access via hostname fails with following message:

Blocked host: discourse_example_net
To allow requests to discourse_example_net, add the following to your environment configuration:
config.hosts << “discourse_example_net”

I found this PR, but I don’t know how to set the env var.

Best,
Luis

2 个赞

You can prepend DISCOURSE_DEV_HOSTS=discourse_example_net to the command that starts the unicorn server, or you can set the variable in your ~/.bashrc (or the rc file of the shell you use).

5 个赞

我尝试了 DISCOURSE_DEV_HOSTS=xxx.ngrok.io d/unicorn,但很遗憾,它没有生效。

我猜你说的“不起作用”是指你仍然遇到了和原始发帖人相同的错误?看起来你正在使用 Docker 进行开发,因此需要在容器内部(而不是主机机器上)设置此环境变量。我开发时不使用 Docker,但看起来 d/boot_dev 可以为你在容器内设置变量:

d/boot_dev -e DISCOURSE_DEV_HOSTS=xxx.ngrok.io

然后运行 d/unicorn

4 个赞

那最终总是会出现

502 错误网关
服务器返回了无效或不完整的响应。