quick-start-nginx.rst 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. ==================================
  2. Install with Nginx (depreciated)
  3. ==================================
  4. This is the old quick start guide, which contains instructions using Nginx and Docker CE. It is recommended to use the new quick start guide with Caddy instead.
  5. 0. Introduction
  6. ==================
  7. We assume for this installation that you want all of the Netmaker features enabled, you want your server to be secure, and you want your server to be accessible from anywhere.
  8. This instance will not be HA. However, it should comfortably handle around one hundred concurrent clients and support the most common use cases.
  9. If you are deploying for a business or enterprise use case and this setup will not fit your needs, please contact [email protected], or check out the business subscription plans at https://gravitl.com/plans/business.
  10. By the end of this guide, you will have Netmaker installed on a public VM linked to your custom domain, secured behind an Nginx reverse proxy.
  11. For information about deploying more advanced configurations, see the :doc:`Advanced Installation <./server-installation>` docs.
  12. 1. Prerequisites
  13. ==================
  14. - **Virtual Machine**
  15. - Preferably from a cloud provider (e.x: DigitalOcean, Linode, AWS, GCP, etc.)
  16. - We do not recommend Oracle Cloud, as VM's here have been known to cause network interference.
  17. - Public, static IP
  18. - Min 1GB RAM, 1 CPU (4GB RAM, 2CPU preferred)
  19. - Nginx may have performance issues if using a cloud VPS with a single, shared CPU
  20. - 2GB+ of storage
  21. - Ubuntu 20.04 Installed
  22. - **Domain**
  23. - A publicly owned domain (e.x. example.com, mysite.biz)
  24. - Permission and access to modify DNS records via DNS service (e.x: Route53)
  25. 2. Install Dependencies
  26. ========================
  27. ``ssh root@your-host``
  28. Install Docker
  29. ---------------
  30. Begin by installing the community version of Docker and docker-compose (there are issues with the snap version). You can follow the official `Docker instructions here <https://docs.docker.com/engine/install/>`_. Or, you can use the below series of commands which should work on Ubuntu 20.04.
  31. .. code-block::
  32. sudo apt-get remove docker docker-engine docker.io containerd runc
  33. sudo apt-get update
  34. sudo apt-get -y install apt-transport-https ca-certificates curl gnupg lsb-release
  35. curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
  36. echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
  37. sudo apt-get update
  38. sudo apt-get -y install docker-ce docker-ce-cli containerd.io
  39. sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
  40. sudo chmod +x /usr/local/bin/docker-compose
  41. docker --version
  42. docker-compose --version
  43. At this point Docker should be installed.
  44. Install Dependencies
  45. -----------------------------
  46. In addition to Docker, this installation requires WireGuard, Nginx, and Certbot.
  47. ``sudo apt -y install wireguard wireguard-tools nginx certbot python3-certbot-nginx net-tools``
  48. 3. Prepare VM
  49. ===============================
  50. Prepare Domain
  51. ----------------------------
  52. 1. Choose a base domain or subdomain for Netmaker. If you own **example.com**, this should be something like **netmaker.example.com**
  53. - You must point your wildcard domain to the public IP of your VM, e.x: *.example.com --> <your public ip>
  54. 2. Add an A record pointing to your VM using your DNS service provider for *.netmaker.example.com (inserting your own subdomain of course).
  55. 3. Netmaker will create three subdomains on top of this. For the example above those subdomains would be:
  56. - dashboard.netmaker.example.com
  57. - api.netmaker.example.com
  58. - grpc.netmaker.example.com
  59. Moving forward we will refer to your base domain using **<your base domain>**. Replace these references with your domain (e.g. netmaker.example.com).
  60. 4. ``nslookup host.<your base domain>`` (inserting your domain) should now return the IP of your VM.
  61. 5. Generate SSL Certificates using certbot:
  62. ``sudo certbot certonly --manual --preferred-challenges=dns --email [email protected] --server https://acme-v02.api.letsencrypt.org/directory --agree-tos --manual-public-ip-logging-ok -d "*.<your base domain>"``
  63. The above command (using your domain instead of <your base domain>), will prompt you to enter a TXT record in your DNS service provider. Do this, and **wait one minute** before clicking enter, or it may fail and you will have to run the command again.
  64. Prepare Firewall
  65. -----------------
  66. Make sure firewall settings are appropriate for Netmaker. You need ports 53 and 443. On the server you can run:
  67. .. code-block::
  68. sudo ufw allow proto tcp from any to any port 443 && sudo ufw allow 53/udp && sudo ufw allow 53/tcp
  69. **Based on your cloud provider, you may also need to set inbound security rules for your server. This will be dependent on your cloud provider. Be sure to check before moving on:**
  70. - allow 443/tcp from all
  71. - allow 53/udp and 53/tcp from all
  72. In addition to the above ports, you will need to make sure that your cloud's firewall or security groups are opened for the range of ports that Netmaker's WireGuard interfaces consume.
  73. Netmaker will create one interface per network, starting from 51821. So, if you plan on having 5 networks, you will want to have at least 51821-51825 open (udp).
  74. Prepare Nginx
  75. -----------------
  76. Nginx will serve the SSL certificate with your chosen domain and forward traffic to netmaker.
  77. Get the nginx configuration file:
  78. ``wget https://raw.githubusercontent.com/gravitl/netmaker/develop/nginx/netmaker-nginx-template.conf``
  79. Insert your domain in the configuration file and add to nginx:
  80. .. code-block::
  81. sed -i 's/NETMAKER_BASE_DOMAIN/<your base domain>/g' netmaker-nginx-template.conf
  82. sudo cp netmaker-nginx-template.conf /etc/nginx/conf.d/<your base domain>.conf
  83. nginx -t && nginx -s reload
  84. systemctl restart nginx
  85. 4. Install Netmaker
  86. ====================
  87. Prepare Templates
  88. ------------------
  89. **Note on COREDNS_IP:** Depending on your cloud provider, the public IP may not be bound directly to the VM on which you are running. In such cases, CoreDNS cannot bind to this IP, and you should use the IP of the default interface on your machine in place of COREDNS_IP. If the public IP **is** bound to the VM, you can simply use the same IP as SERVER_PUBLIC_IP.
  90. .. code-block::
  91. wget https://raw.githubusercontent.com/gravitl/netmaker/develop/compose/docker-compose.yml
  92. sed -i 's/NETMAKER_BASE_DOMAIN/<your base domain>/g' docker-compose.yml
  93. sed -i 's/SERVER_PUBLIC_IP/<your server ip>/g' docker-compose.yml
  94. sed -i 's/COREDNS_IP/<your server ip>/g' docker-compose.yml
  95. Generate a unique master key and insert it:
  96. .. code-block::
  97. tr -dc A-Za-z0-9 </dev/urandom | head -c 30 ; echo ''
  98. sed -i 's/REPLACE_MASTER_KEY/<your generated key>/g' docker-compose.yml
  99. You may want to save this key for future use with the API.
  100. Start Netmaker
  101. ----------------
  102. ``sudo docker-compose -f docker-compose.yml up -d``
  103. navigate to dashboard.<your base domain> to log into the UI.
  104. To troubleshoot issues, start with:
  105. ``docker logs netmaker``
  106. Or check out the :doc:`troubleshoooting docs <./troubleshoot>`.