{"id":3379,"date":"2025-02-12T19:59:01","date_gmt":"2022-01-07T07:44:58","guid":{"rendered":""},"modified":"2025-02-02T00:46:20","modified_gmt":"2025-02-01T23:46:20","slug":"how-to-install-nodebb-with-mongodb-and-nginx-proxy-on-almalinux-9-using-docker-and-ansible","status":"publish","type":"post","link":"https:\/\/netcloud24.com\/knowledgebase\/how-to-install-nodebb-with-mongodb-and-nginx-proxy-on-almalinux-9-using-docker-and-ansible\/","title":{"rendered":"Linux VPS &#038; VPS Windows Setup Guide | NetCloud24 NodeBB with MongoDB and Nginx Proxy on AlmaLinux 9 using Docker and Ansible"},"content":{"rendered":"<p>\u00a0<\/p>\n<\/p>\n<header>\n<h1>\u00a0<\/h1>\n<p>A Comprehensive Step-by-Step Guide<\/p>\n<\/header>\n<section>\n<h2>Introduction<\/h2>\n<p>NodeBB is a modern, open-source forum software built on Node.js. It is designed to be fast, scalable, and easy to use. MongoDB is a NoSQL database that works seamlessly with NodeBB, while Nginx acts as a reverse proxy to handle incoming requests efficiently.<\/p>\n<p>In this guide, we will walk you through the process of installing NodeBB with MongoDB and Nginx Proxy on AlmaLinux 9 using Docker and Ansible. By the end of this article, you will have a fully functional NodeBB forum running in a Dockerized environment, managed by Ansible.<\/p>\n<\/section>\n<section>\n<h2>Prerequisites<\/h2>\n<p>Before we begin, ensure that you have the following prerequisites:<\/p>\n<ul>\n<li><strong>AlmaLinux 9:<\/strong> A server running AlmaLinux 9 with root or sudo access.<\/li>\n<li><strong>Docker:<\/strong> Docker installed on your AlmaLinux 9 server. You can follow the <a href=\"https:\/\/docs.docker.com\/engine\/install\/\" target=\"_blank\" rel=\"follow\">official Docker installation guide<\/a>.<\/li>\n<li><strong>Docker Compose:<\/strong> Docker Compose installed. Follow the <a href=\"https:\/\/docs.docker.com\/compose\/install\/\" target=\"_blank\" rel=\"follow\">official Docker Compose installation guide<\/a>.<\/li>\n<li><strong>Ansible:<\/strong> Ansible installed on your local machine or control node. Follow the <a href=\"https:\/\/docs.ansible.com\/ansible\/latest\/installation_guide\/intro_installation.html\" target=\"_blank\" rel=\"follow\">official Ansible installation guide<\/a>.<\/li>\n<li><strong>Basic Knowledge:<\/strong> Familiarity with Docker, Ansible, and Linux command-line operations.<\/li>\n<\/ul>\n<\/section>\n<section>\n<h2>Step 1: Set Up Docker and Docker Compose<\/h2>\n<p>First, ensure that Docker and Docker Compose are installed and running on your AlmaLinux 9 server.<\/p>\n<h3>Install Docker<\/h3>\n<pre><code>sudo dnf config-manager --add-repo=https:\/\/download.docker.com\/linux\/centos\/docker-ce.repo\r\nsudo dnf install docker-ce docker-ce-cli containerd.io\r\nsudo systemctl start docker\r\nsudo systemctl enable docker<\/code><\/pre>\n<h3>Install Docker Compose<\/h3>\n<pre><code>sudo curl -L \"https:\/\/github.com\/docker\/compose\/releases\/download\/v2.20.0\/docker-compose-$(uname -s)-$(uname -m)\" -o \/usr\/local\/bin\/docker-compose\r\nsudo chmod +x \/usr\/local\/bin\/docker-compose<\/code><\/pre>\n<\/section>\n<section>\n<h2>Step 2: Create a Docker Compose File for NodeBB and MongoDB<\/h2>\n<p>Create a directory for your NodeBB setup and navigate into it:<\/p>\n<pre><code>mkdir nodebb-setup\r\ncd nodebb-setup<\/code><\/pre>\n<p>Create a <code>docker-compose.yml<\/code> file:<\/p>\n<pre><code>version: '3.8'\r\n\r\nservices:\r\n  mongo:\r\n    image: mongo:5.0\r\n    container_name: mongo\r\n    restart: always\r\n    volumes:\r\n      - mongo_data:\/data\/db\r\n    networks:\r\n      - nodebb_network\r\n\r\n  nodebb:\r\n    image: nodebb\/nodebb:latest\r\n    container_name: nodebb\r\n    restart: always\r\n    ports:\r\n      - \"4567:4567\"\r\n    links:\r\n      - mongo\r\n    environment:\r\n      - DATABASE=mongo\r\n      - MONGO_HOST=mongo\r\n      - MONGO_PORT=27017\r\n      - MONGO_USER=nodebb\r\n      - MONGO_PASSWORD=nodebbpassword\r\n      - MONGO_DATABASE=nodebb\r\n    volumes:\r\n      - nodebb_data:\/var\/lib\/nodebb\r\n    networks:\r\n      - nodebb_network\r\n\r\n  nginx:\r\n    image: nginx:latest\r\n    container_name: nginx\r\n    restart: always\r\n    ports:\r\n      - \"80:80\"\r\n      - \"443:443\"\r\n    volumes:\r\n      - .\/nginx.conf:\/etc\/nginx\/nginx.conf\r\n    networks:\r\n      - nodebb_network\r\n\r\nvolumes:\r\n  mongo_data:\r\n  nodebb_data:\r\n\r\nnetworks:\r\n  nodebb_network:<\/code><\/pre>\n<p>This Docker Compose file defines three services: MongoDB, NodeBB, and Nginx. It also creates Docker volumes for persistent data storage.<\/p>\n<\/section>\n<section>\n<h2>Step 3: Configure Nginx as a Reverse Proxy<\/h2>\n<p>Create an <code>nginx.conf<\/code> file in the same directory:<\/p>\n<pre><code>events {}\r\n\r\nhttp {\r\n    server {\r\n        listen 80;\r\n        server_name yourdomain.com;\r\n\r\n        location \/ {\r\n            proxy_pass http:\/\/nodebb:4567;\r\n            proxy_set_header Host $host;\r\n            proxy_set_header X-Real-IP $remote_addr;\r\n            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\r\n            proxy_set_header X-Forwarded-Proto $scheme;\r\n        }\r\n    }\r\n}<\/code><\/pre>\n<p>Replace <code>yourdomain.com<\/code> with your actual domain name. This configuration forwards incoming HTTP requests to the NodeBB container.<\/p>\n<\/section>\n<section>\n<h2>Step 4: Deploy with Docker Compose<\/h2>\n<p>Run the following command to start the containers:<\/p>\n<pre><code>docker-compose up -d<\/code><\/pre>\n<p>This command will pull the required Docker images and start the MongoDB, NodeBB, and Nginx containers in detached mode.<\/p>\n<\/section>\n<section>\n<h2>Step 5: Automate with Ansible<\/h2>\n<p>To automate the deployment process, create an Ansible playbook named <code>deploy_nodebb.yml<\/code>:<\/p>\n<pre><code>---\r\n- hosts: all\r\n  become: yes\r\n  tasks:\r\n    - name: Ensure Docker is installed\r\n      dnf:\r\n        name: docker-ce\r\n        state: present\r\n\r\n    - name: Ensure Docker Compose is installed\r\n      get_url:\r\n        url: https:\/\/github.com\/docker\/compose\/releases\/download\/v2.20.0\/docker-compose-$(uname -s)-$(uname -m)\r\n        dest: \/usr\/local\/bin\/docker-compose\r\n        mode: '0755'\r\n\r\n    - name: Start and enable Docker service\r\n      service:\r\n        name: docker\r\n        state: started\r\n        enabled: yes\r\n\r\n    - name: Create NodeBB setup directory\r\n      file:\r\n        path: \/opt\/nodebb-setup\r\n        state: directory\r\n\r\n    - name: Copy Docker Compose file\r\n      copy:\r\n        src: docker-compose.yml\r\n        dest: \/opt\/nodebb-setup\/docker-compose.yml\r\n\r\n    - name: Copy Nginx configuration\r\n      copy:\r\n        src: nginx.conf\r\n        dest: \/opt\/nodebb-setup\/nginx.conf\r\n\r\n    - name: Deploy NodeBB with Docker Compose\r\n      command: docker-compose up -d\r\n      args:\r\n        chdir: \/opt\/nodebb-setup<\/code><\/pre>\n<p>Run the playbook using the following command:<\/p>\n<pre><code>ansible-playbook -i your_inventory_file deploy_nodebb.yml<\/code><\/pre>\n<p>Replace <code>your_inventory_file<\/code> with the path to your Ansible inventory file.<\/p>\n<\/section>\n<section>\n<h2>Step 6: Access NodeBB<\/h2>\n<p>Once the deployment is complete, open your web browser and navigate to <code>http:\/\/yourdomain.com<\/code>. You should see the NodeBB setup wizard. Follow the on-screen instructions to complete the installation.<\/p>\n<\/section>\n<section>\n<h2>Conclusion<\/h2>\n<p>In this guide, we walked you through the process of installing NodeBB with MongoDB and Nginx Proxy on AlmaLinux 9 using Docker and Ansible. By following these steps, you can easily set up a scalable and efficient forum platform.<\/p>\n<p>Docker and Ansible make it easy to manage and automate your deployments, ensuring a smooth and consistent setup process. Whether you&#8217;re running a small community forum or a large-scale discussion platform, this setup provides a robust foundation for your needs.<\/p>\n<\/section>\n<footer>\n<p>\u00a0<\/p>\n<\/footer>\n<div class=\"post-author-box\" style=\"border-top:1px solid #ddd;margin-top:20px;padding-top:15px;\">\n<p><strong>Author:<\/strong> \u0141ukasz Bodziony<\/p>\n<p><strong>Website:<\/strong> <a href=\"https:\/\/ca.netcloud24.com\" target=\"_blank\" rel=\"dofollow\">Windows VPS<\/a><\/p>\n<p><em>\u0141ukasz Bodziony is the CEO and founder of <a href=\"https:\/\/netcloud24.com\" target=\"_blank\" rel=\"dofollow\">NETCLOUD24<\/a>, a global VPS hosting brand proudly originating from Poland. With extensive experience in cloud computing, virtualization, and server management, he delivers high-performance <strong>Windows VPS<\/strong> and <strong>Remote Desktop Services (RDS)<\/strong> solutions to clients across Europe, North America, and beyond.<\/em><\/p>\n<p><em>His expertise covers a wide range of technologies, including <strong>Microsoft Azure<\/strong>, <strong>Proxmox VE<\/strong>, <strong>Amazon Web Services (AWS)<\/strong>, and numerous other virtualization and cloud platforms.<\/em><\/p>\n<p><em>Beyond running his hosting business, \u0141ukasz also provides <strong>professional paid server configuration and optimization services<\/strong> for companies and individuals. Outside of work, he is dedicated to caring for his children and building a secure future for them.<\/em><\/p>\n<p><em>If you are interested in working with him or need expert assistance with your hosting, cloud environment, or server setup, feel free to reach out via <a href=\"https:\/\/ca.netcloud24.com\" target=\"_blank\" rel=\"dofollow\">Windows VPS<\/a>.<\/em><\/p>\n<\/p><\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u00a0 \u00a0 A Comprehensive Step-by-Step Guide Introduction NodeBB is a modern, open-source forum software built on Node.js. It is designed to be fast, scalable, and easy to use.\u2026<\/p>\n","protected":false},"author":1,"featured_media":3421,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_seopress_robots_primary_cat":"","_seopress_titles_title":"","_seopress_titles_desc":"","_seopress_robots_index":"","footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[],"tags":[14,12,11,23,20,21,22,17,7,8,6,10,18,19,15,24,16,5,13,9],"class_list":["post-3379","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","tag-cheapvps","tag-cloudvps","tag-hostingvps","tag-rds","tag-rdscal","tag-remotedesktop","tag-remotedesktopvps","tag-servervps","tag-ukvps","tag-virtualserver","tag-vpshosting","tag-vpsserver","tag-vpssolutions","tag-vpswindows","tag-vpswithwindows","tag-windowsrds","tag-windowsserver","tag-windowsvps","tag-windowsvpshosting","tag-windowsvpsuk"],"jetpack_publicize_connections":[],"_links":{"self":[{"href":"https:\/\/netcloud24.com\/knowledgebase\/wp-json\/wp\/v2\/posts\/3379","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/netcloud24.com\/knowledgebase\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/netcloud24.com\/knowledgebase\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/netcloud24.com\/knowledgebase\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/netcloud24.com\/knowledgebase\/wp-json\/wp\/v2\/comments?post=3379"}],"version-history":[{"count":0,"href":"https:\/\/netcloud24.com\/knowledgebase\/wp-json\/wp\/v2\/posts\/3379\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/netcloud24.com\/knowledgebase\/wp-json\/wp\/v2\/media\/3421"}],"wp:attachment":[{"href":"https:\/\/netcloud24.com\/knowledgebase\/wp-json\/wp\/v2\/media?parent=3379"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/netcloud24.com\/knowledgebase\/wp-json\/wp\/v2\/categories?post=3379"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/netcloud24.com\/knowledgebase\/wp-json\/wp\/v2\/tags?post=3379"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}