您好。
我知道建议将 Discourse 部署在独立的服务器上,但我是自费运行这个项目,它基本上是一个爱好,至少在短期内没有盈利的前景或意图。
因此,我在想,与其再购买一台 VPS,不如申请第二个 IP 地址,并在基于 IP 的 Apache 虚拟服务器上运行 WordPress,这样有助于降低成本。
这样做可行吗?还是不被推荐?
您好。
我知道建议将 Discourse 部署在独立的服务器上,但我是自费运行这个项目,它基本上是一个爱好,至少在短期内没有盈利的前景或意图。
因此,我在想,与其再购买一台 VPS,不如申请第二个 IP 地址,并在基于 IP 的 Apache 虚拟服务器上运行 WordPress,这样有助于降低成本。
这样做可行吗?还是不被推荐?
If you are familiar with reverse proxy configuration, you don’t need the second IP.
You can run both Discourse and Wordpress listening on unix sockets (or higher ports) and run a reverse proxy software in front (I recommend Caddy) to serve on the same IP your blog.example.com and forum.example.com.
That said, if you aren’t familiar with this type of setup, running each in it’s own VPS is much easier as you can just follow the vast documentation for each.
Can that setup you recommend work without issues?
I did something with haproxy when I was initially trying discourse. I was somewhat of a noob and still am in matters of servers and stuff but did anyway, and learned a bit about haproxy in the process. If I recall correctly there were issues with SSL, and the behavior of discourse whas somewhat inestable but guess I did I do something wrong.
So my question is it possible to do the configuration you recommend without instability and “funny” issues, without extreme amounts of fine tuning?
Yes, if you properly configure you reverse proxy it is possible. That is how this site right here is run.
What we can’t do is offer support to every reverse proxy configuration here.
Awesome!
Last petition: can you link me to some help documentation to do this configuration?
Nginx Running other websites on the same machine as Discourse
Caddy Running Discourse with Caddy Server
Apache How to set up Discourse on a server with existing Apache sites
Lovely.
I remember when I did my trials I followed the apache guide. What is nor clear from the article is whether SSL should be disabled upon rebuilding discourse (and whether disabling it is accomplished by just not entering an email address for let’s encrypt), and what ports should be “exposed” on discourse/app.yml (the guide only shows who the line …
“8888:80” # fwd host port 8888 to container port 80 (http)
… is supposed to look, but nothing about the immediately following line in the app.yml file (the one than by default looks…
… should look like.
PS. While looking at the app.yml file to write that post I realized the following lines are present there:
##Uncomment these two lines if you wish to add Lets Encrypt (https)
… however, as of right now, my discourse app is running with SSL enabled but with these likes uncommented. How crucial commenting these lines is for my current setup (without a proxy) or for my desired setup (with a proxy and apache-wordpress)?

If you are not familiar with reverse proxies, and you can get a second IP easily, then that’s not a bad solution. Just do something like this:
expose:
- "192.168.1.1:80:80" # http
- "192.168.1.1:443:443" # https
This did it.
Love.
.
You can do the same trick with Straightforward direct-delivery incoming mail.
谢谢,这对我很有帮助。我的 VPS 提供商除了 VPS 上配置的主 IP 外,还提供廉价的“浮动 IP
那成功了?我没想到 Droplet 会知道浮动 IP 的存在。
嗯,它运行得很好:
首先购买一个浮动 IP 并将其绑定到我的 VPS。
然后配置服务器以使用该 IP:
vim /etc/network/interfaces.d/60-my-floating-ip.cfg
auto eth0:1
iface eth0:1 inet static
address your.Float.ing.IP
netmask 32
保存后,重启网络:
sudo service networking restart
现在我有两个 IP:我使用主 IP 来配置多个 nginx 站点,请注意 /etc/nginx/sites-enabled 中的配置行:
listen my_main_IP:80 myserver.name;
listen my_main_IP:443 ssl http2 myserver.name;
而在 /var/discourse/containers/app.yml 中,浮动 IP 的配置如下:
expose:
- "my_floating_ip:80:80"
- "my_floating_ip:443:443"
检查一切是否正常(原始 IP 已替换为 floating_ip 和 main_ip):
# netstat -taunp | grep -i listen
tcp 0 0 floating_ip:80 0.0.0.0:* LISTEN 19775/docker-proxy
tcp 0 0 main_ip:80 0.0.0.0:* LISTEN 13151/nginx: master
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 725/sshd
tcp 0 0 floating_ip:443 0.0.0.0:* LISTEN 19763/docker-proxy
tcp 0 0 main_ip:443 0.0.0.0:* LISTEN 13151/nginx: master
tcp6 0 0 :::22 :::* LISTEN 725/sshd
我不知道是否适合提及具体名称,但服务器托管在 Hetzner Cloud 上,其浮动 IP 功能非常便捷且定价合理。
我知道这是一个比较老的话题,但我想感谢你们,这可能会为我正在处理的一个类似问题节省数天的工作。感谢你们与大家分享这些宝贵的信息!!