Question

How to Install Subspace on Ubuntu server?

Subspace is a simple opensource WireGuard VPN server graphical user interface(GUI). You can install subspace directly on your server which would allow you to track and create client configurations.

Subspace is an open-source, self-hosted front end GUI (graphical user interface) for the Wireguard VPN system on the server-side. Once set up it provides a browser-accessible system to track clients and create client configurations for connecting to the server.

Some of the features of Subspace are:

  • WireGuard VPN Protocol.
  • Single Sign-On (SSO) with SAML.
  • Add new devices, connect from Mac OS X, Windows, Linux, Android, or iOS.
  • Remove Devices, removes client key, and disconnect clients.
  • Auto-generated Configs.
Show comments

Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Bobby Iliev
Site Moderator
Site Moderator badge
June 9, 2020
Accepted Answer

Prerequisites

In order to complete this guide, you will first need to perform the following tasks on your Ubuntu 18.04 Droplet:

Step 1 — Install WireGuard

First, update your existing list of packages:

  1. sudo apt update

Add the WireGuard PPA to the system to configure access to the project’s packages:

  1. sudo add-apt-repository -y ppa:wireguard/wireguard

Once the PPA has been added, update the local package index to pull down information about the newly available packages and then install the WireGuard kernel module and userland components:

  1. sudo apt update
  2. sudo apt install wireguard-dkms wireguard-tools

Remove dnsmasq because it will run inside the container:

  1. sudo apt remove -y dnsmasq

Disable systemd-resolved if it blocks port 53.

  1. sudo systemctl disable systemd-resolved
  2. sudo systemctl stop systemd-resolved

After that setup CloudFlare as your DNS server:

echo nameserver 1.1.1.1 | sudo tee /etc/resolv.conf

Step 2 — WireGuard modules

In order to load the required WireGuard modules you need to run the following commands:

  1. sudo modprobe wireguard
  2. sudo modprobe iptable_nat
  3. sudo modprobe ip6table_nat

Once the modules have been enabled you need to run the following commands in order to enable the modules when the server gets rebooted:

  1. echo "wireguard" | sudo tee /etc/modules-load.d/wireguard.conf
  2. echo "iptable_nat" | sudo tee /etc/modules-load.d/iptable_nat.conf
  3. echo "ip6table_nat" | sudo tee /etc/modules-load.d/ip6table_nat.conf

Finally check if systemd-modules-load service is active:

sudo systemctl status systemd-modules-load.service

Step 3 - Enable packet Packet forwarding

In order to get WireGuired to work as expected, we need to make sure that package forwarding is enabled. Packet forwarding means allowing packets to go from one network to another.

To do that you need to run the following commands:

  1. sudo sysctl -w net.ipv4.ip_forward=1
  2. sudo sysctl -w net.ipv6.conf.all.forwarding=1

Step 4 - Configure Domain name DNS

In order to use Let’s Encrypt and secure our Subspace instance, we need to make sure that we have a domain name that points to our Droplet’s IP address.

To do that make sure to create a DNS A record for your domain or subdomain name and point it to your server’s IP address.

Example:

subspace.your_domain.com A 172.16.1.1

Step 5 - Firewall Rules

As subspace runs a TLS (“SSL”) https server on port 443/tcp and a standard web server on port 80/tcp, we need to make sure that the two ports are open for incoming TCP traffic via our firewall. To do that run the following commands

  1. sudo ufw allow 80
  2. sudo ufw allow 443

Also, as port 51820/udp is the default WireGurad port, we need to make sure that it is open as well:

  1. sudo ufw allow 51820/udp

Next, we need to start the subspace Docker container.

Step 6 - Start subspace

Your data directory should be bind-mounted as /data inside the container using the --volume flag.

  1. sudo mkdir /data

After that, we need to create our container. Make sure to change the --env SUBSPACE_HTTP_HOST to your domain name which is pointing to your Droplet.

docker create \
    --name subspace \
    --restart always \
    --network host \
    --cap-add NET_ADMIN \
    --volume /usr/bin/wg:/usr/bin/wg \
    --volume /data:/data \
    --volume /lib/x86_64-linux-gnu/libc.so.6:/lib/x86_64-linux-gnu/libc.so.6:ro \
    --volume /lib64/ld-linux-x86-64.so.2:/lib64/ld-linux-x86-64.so.2:ro \
    --env SUBSPACE_HTTP_HOST="subspace.example.com" \
    --env SUBSPACE_NAMESERVER="1.1.1.1" \
    subspacecommunity/subspace:latest

Then start your container:

  1. sudo docker start subspace

You can also check the logs of your container to make sure that it starts as expected:

  1. sudo docker logs subspace

Then visit your domain name via your browser and you will be able to see your subspace installation!

Conclusion

The subspacecommunity/subspace project is community maintained and is a fork of the simple WireGuard VPN server GUI. If you notice any problems feel free to submit an issue or a pull request!

Hope that this helps! Regards, Bobby

Hi ! The Wireguard VPN doesn’t isolate clients on default. If i want to enable client isolation ??? tnx

403 urn:acme:error:unauthorized: Account creation on ACMEv1 is disabled. Please upgrade your ACME client to a version that supports ACMEv2 / RFC 8555. See https://community.letsencrypt.org/t/end-of-life-plan-for-acmev1/88430 for details.

someone forgot to update subspace ACME client…

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel