Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to deploy Discourse Forum with site-wide CDN

2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

This article will explain in detail how to use the site-wide CDN to deploy the Discourse forum. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.

Discourse introduction

Discourse is an open source forum developed by Jeff Atwood, co-founder of Stack Overflow, based on Ruby on Rails. Compared with traditional forums, Discourse is proving itself to be a product designed for the next decade of the Internet, from his open source attitude, clear page style to its unique content operation system. Now, foreign well-known products such as Car Talk all adopt Discourse as the forum scheme.

As an open source forum project, Discourse has the following highlights compared to other forums:

Highly customizable: from the post level requirements to the minimum number of words in the forum post title requirements, Discourse in the forum settings listed 25 settings major, 300 + forum items, even if we all use Discourse to build the forum, but each forum built with Discourse has its own style.

Plug-ins: Discourse official and Discourse open source community users have developed a wealth of plug-ins for use, such as personalized navigation, custom forum covers.

Integration: can be connected to third-party products, including Google Analytics, Slack and Wordpress.

Free: although Discourse has a hosting service of $100/Month, you can deploy the free Discourse service entirely on your own.

Other: Discourse has many other benefits, for example, it provides a robot Discobot   is a customizable bot that interactively teaches new users to use many of the platform's features, such as bookmarking topics), single-frame links (embedded preview), adding emoji emoticons, very simple formatting, adding picture replies, tagging posts and how to use the search function.

Rich plug-ins and customizable forum settings are the biggest reasons why Nebula Graph chooses Discourse. This article is not intended to introduce how to build Discourse (building Discourse is a simple activity, you can search for tutorials on your own). The purpose of this article is to introduce how the graph database Nebula graph uses CDN to deploy Discourse.

Reasons for deploying Discourse self-hosting

Despite Discourse's official hosting service, we decided to host this service ourselves because of the unstable quality of domestic access and the lack of freedom to modify plug-ins and custom network settings. Based on the self-hosting service, we have made some custom modifications to the network and plug-in system, so that the current Nebula Graph community has better access speed and functions.

Self-hosted forum service requirements

After testing, the following configuration list can fully meet the requirements for our deployment of Discourse:

For Linux servers with more than 2 GB of memory, if you use hosts with 1 GB of memory, you need to open the SWAP partition.

We will use it when registering email services and CDN services with full control of the domain name.

A Cloudflare account, which will help speed up the site and improve security.

An available SMTP mail service.

Deploy Docker service for Linux server. Domestic users can add image domain names of Azure China and Qiniuyun.

Introduction to deployment practice Cloudflare

Cloudflare is a CDN service provider covering major regions of the world, providing basic CDN services as well as high-quality DNS queries, DDOS protection and cache acceleration services. Compared with other CDN service providers, their product concept is more advanced, not only has a good service quality and has a very low price (usually even free), so the current scale of Cloudflare users is very large, is worthy of the first choice of CDN service providers.

Set DNS record for Cloudflare

Setting the DNS record first reduces the probability that you cannot apply for a certificate through Let's encrypt on the first deployment. In Cloudflare's DNS configuration, add a record of type A that points to the IP address of the server.

As a reminder, do not set Proxy status to "Proxied", which will cause the page to be inaccessible due to too many redirects. We will turn on the Proxy status setting after completing the correct configuration.

Configure Cloudflare SSL/TLS

Full and Flexible are the two most commonly used SSL modes on Cloudflare and need to be set before CDN is enabled correctly. First of all, go to the SSL/TLS settings panel and select Full mode, which will ensure that the origin server can also be accessed through HTTPS when the CDN is back to origin, which effectively improves the security of the content.

Then go to the Origin Server tag to create the certificate, and select RSA,BTW among the private key types, which is the most compatible certificate type, while ECDSA has better performance.

Enter the domain name of the forum in the list of domain names protected by the certificate, for example, the address of the Nebula Graph forum is: discuss.nebula-graph.io, and the certificate is valid for one year. After clicking Next, you will get the public key and private key of the certificate, save them as "ssl.crt" and "ssl.key" respectively, and we will use them in the following steps.

Configure and deploy Discourse

Discourse has a complete Docker image, so you can run it directly after the correct installation of Docker.

Install Discourse

Pull the official Discourse Docker image to the / var/discourse directory.

Sudo-sgit clone https://github.com/discourse/discourse_docker.git / var/discoursecd / var/discourse

Execute under the / var/discourse directory

. / discourse-setup

You can see the following interactive interface, in which you can fill in the domain name, administrator mailbox, SMTP mail server information and Let's Encrypt notification mailbox address to complete the basic configuration of the forum.

Hostname for your Discourse? [discourse.example.com]: [domain name of the forum] Email address for admin account (s)? [me@example.com,you@example.com]: [administrator mailbox, this mailbox will not be made public] SMTP server address? [smtp.example.com]: [SMTP mail server address] SMTP port? [587]: [SMTP mail server port] SMTP user name? [user@example.com]: [forum automatic email account] SMTP password? [pa$$word]: [password of email account automatically sent by forum] Let's Encrypt account email? (ENTER to skip) [me@example.com]: [automatically update the notification email address of the certificate] SSL considerations

One thing to note when using SSL is that if the DNS record has not been propagated to the DNS server used by the server, you will not be able to use Let's Encrypt's SSL certificate auto-enrollment service. Since we will use the Cloudflare certificate we applied for above, we can skip the Let's Encrypt account email here.

Forum launch

After waiting for about 10 minutes, you can access your Discourse forum through the previously set domain name: discuss.nebula-graph.io. If a 502 error occurs on the first access, this is due to the fact that the service has not been fully initialized, usually after a while.

Configure Discourse

The configuration file for Discourse is located in / var/discourse/containers/app.yml

Mail Service Settings

The mail service is one of the parts that are prone to setup errors throughout the deployment process. For most mail services, the correct configuration of the SMTP server address, port and sender's account password can be completed. The SMTP server address and available ports are usually found on the mail service provider's help page, and some personal mailboxes may need to create an application-specific password to use the SMTP service.

However, for Office365 and enterprise mailboxes like Tencent, you need to manually specify the account verification method as login in app.yml. The reference configuration is as follows:

DISCOURSE_SMTP_ADDRESS: smtp.office365.com DISCOURSE_SMTP_PORT: 587DISCOURSE_SMTP_USER_NAME: example@office365.com DISCOURSE_SMTP_PASSWORD: * DISCOURSE_SMTP_ENABLE_START_TLS: true DISCOURSE_SMTP_AUTHENTICATION: login

This is because the default mailbox authentication method for Discourse is plain. If you are not sure how to authenticate, you can use swaks, a mail service testing tool, to monitor. Reference:

Swaks-- to [receive mailbox]-- from [outgoing mailbox]-- server [SMTP server address]-- auth [login/plain]-auth-user [outgoing mailbox]-tls-p [port]

While ensuring that tests can be sent via Discourse email, there are also two feature settings to ensure that users can receive email.

The notification email located under the forum Setting-Required needs to be configured with the same email address as the SMTP login account.

Disable emails, usually after forum migration, backup and restore, this item is usually set to non-staff. At this time, the recovery mail will be sent when it is set to no.

SSL, CDN service settings

In the app.yml file, templates/cloudflare.template.yml and templates/web.ssl.template.yml template files are introduced under tempates. Log in to the Cloudflare account again, change the DNS record from DNS only to Proxied, and wait for the record to take effect. If the local network quality is not good, you can also introduce the templates/web.china.template.yml template, which will obtain resources from the domestic Ruby image.

Templates:-"templates/postgres.template.yml"-"templates/redis.template.yml"-"templates/web.template.yml"-"templates/web.ratelimited.template.yml"-"templates/cloudflare.template.yml" # # Uncomment these two lines if you wish to add Lets Encrypt (https)-"templates/web.ssl.template.yml"-"templates/web.letsencrypt.ssl.template.yml"

Drop in the certificate file created in step 2 in the / var/discourse/shared/standalone/ `ssl directory.

Add a new plug-in (optional)

In order to better help overseas users read the Chinese content on the forum, we have introduced a translation plug-in. Discourse has a wealth of plug-ins, so you can install any plug-in you are interested in if necessary.

Configure the link that can be obtained by git under the hooks field of the app.yml file, and the new plug-in is installed when the Docker container of Discourse is recreated.

# # Plugins go here## see https://meta.discourse.org/t/19157 for detailshooks: after_code:-exec: cd: $home/plugins cmd:-git clone https://github.com/discourse/docker_manager.git-git clone https://github.com/discourse/discourse-translator.git after configuration

After the above configuration, run. / launcher rebuild app in the / var/discourse directory and wait another 10 minutes to complete the final build.

For individual webmasters, you also need to install and configure Fail2ban to protect the security of ssh services. Discourse automatically creates a backup every week and saves it in the local / var/discourse/shared/standalone/backups directory, which can be backed up by rsync to a local server. If an Amazon S3 service is available, you can also configure information about the S3 service in the background. Discourse will automatically upload the backup to the corresponding S3 instance after completing the backup.

Now you have a Discourse forum with full-site CDN acceleration, which can be securely accessed anywhere in the world thanks to full-site CDN and full-link SSL. Access the forum from your domain name, and according to the information you need to fill in, you can initialize the forum and create an administrator account. After confirming registration through the link in the email, you can start the forum service.

This is the end of this article on "how to use CDN to deploy Discourse Forum". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report