WordPress を 2 つ目の IP と同じ VPS で実行できますか?

こんにちは。

Discourse は独自のサーバーで実行することが推奨されていますが、このプロジェクトは私自身の費用で運営しており、基本的には趣味の範囲です。少なくとも短期的には収益化の展望や意図はほとんどありません。

そのため、別の VPS を購入する代わりに、2 つ目の 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.

「いいね!」 5

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

「いいね!」 3

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…

  • “443:443” # https

… 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)

  • “templates/web.ssl.template.yml”
  • “templates/web.letsencrypt.ssl.template.yml”

… 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)?

:slight_smile:

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
「いいね!」 2

This did it.

Love.
.

「いいね!」 2

You can do the same trick with Straightforward direct-delivery incoming mail.

ありがとうございます。これで解決しました。私の VPS プロバイダーは、VPS に設定されたメインの IP に加えて、安価な「フローティング IP」を提供しています。このソリューションは私にとって非常に便利で、シンプルであるだけに、もっとよく文書化されるべきだと思います。

expose:
   - "my_floating_ip:80:80"
   - "my_floating_ip:443:443"

それでうまくいきましたか?ドロプレットがフローティング IP のことを知っているとは思いませんでした。

さて、問題なく動作しています:

まず、フローティングIPを購入してVPSに紐付けます。
次に、サーバーがそれを使用するように設定します:

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

これで2つのIPアドレスが使えるようになりました。メインのIPを使って複数のnginxサイトを構成していますが、/etc/nginx/sites-enabled の設定行にご注意ください:

listen my_main_IP:80 myserver.name;
listen my_main_IP:443 ssl http2 myserver.name;

そしてフローティングIPは /var/discourse/containers/app.yml で以下のように設定します:

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機能はとても便利で価格も適切です。

「いいね!」 2

なるほど!そんなことができるなんて知りませんでした!

このテクニックを使えば、複数のドメイン向けの 複数の受信メールサーバー を実行することもできます。

素晴らしい仕事ですね!

なるほど!だから仕組みがわからなかったんですね。

「いいね!」 3

これは古いトピックであることは承知していますが、皆さんに感謝したかったのです。これは、私が取り組んできた同様の問題に対する数日間の作業を節約できるかもしれません。この貴重な情報を皆さんと共有してくれてありがとう!!

「いいね!」 2