HTTPS
With HTTPS your password, your backups and your clients’ subscription links travel encrypted. Bridges and exit servers also join only a panel that has HTTPS. AFTAB gets a free Let’s Encrypt certificate and renews it by itself.
Choose a way
Section titled “Choose a way”| Way | Use it when | Command |
|---|---|---|
| A domain | The domain’s A record points to this server | sudo aftab ssl domain vpn.example.com |
| A domain on Cloudflare | You want to keep Cloudflare’s proxy on, or port 80 is not free | sudo aftab ssl cloudflare vpn.example.com |
| This server’s IP address | You have no domain | sudo aftab ssl ip |
| Your own files | You already have a certificate and a key | sudo aftab tls --cert FULLCHAIN.pem --key KEY.pem |
You can also do it in the panel: Settings → Panel → Get a certificate. When it is done the panel restarts with HTTPS, and sudo aftab info shows the new address.
In the installer
Section titled “In the installer”The installer asks Choose [1-3], unless it already has a domain: AFTAB_DOMAIN, or an AFTAB_PUBLIC_HOST that is a domain name, which it then uses without asking. 1 is a domain that points to this server, and the installer then asks for the name. 2 is this server’s IP address, with a certificate that lasts 6 days and renews itself. 3, or just Enter, is not now: the installer skips HTTPS, and the panel stays on plain HTTP until you add it, in the panel or with a command above. Answers 1 and 2 need TCP port 80 open at your provider’s firewall before you answer. In a script nobody can answer: see Install.
What each way needs
Section titled “What each way needs”A domain and the IP address both need TCP port 80 open for a few seconds while Let’s Encrypt checks the server. For a domain, the A record must point here and Cloudflare’s proxy must be off. The IP certificate lasts 6 days and renews by itself before it ends.
Cloudflare checks the domain through Cloudflare’s DNS, so port 80 is not needed and the proxy can stay on. Make an API token with the “Edit zone DNS” permission for the zone and pass it as CF_Token:
sudo CF_Token=YOUR_TOKEN aftab ssl cloudflare vpn.example.comA token typed on the command line stays in your shell history and shows in the process list while the command runs, so make it with only that one permission, for this zone.
Behind the proxy the panel needs a port Cloudflare passes, such as 2053 or 8443. Move the panel to one with sudo aftab port 2053, open that port at your provider’s firewall, and read the new address with sudo aftab info. A browser uses port 443 when an address has no port at all.
Your own files are not renewed by AFTAB. Add --domain to name the domain the certificate is for, and --off goes back to plain HTTP.
Use the domain in client configs
Section titled “Use the domain in client configs”If your domain points straight at the server, not through a CDN, you can use it in client configs too, so they keep working if the IP ever changes. The installer does not ask about it. In the panel, tick “Use the domain in client configs too” when you get the certificate. On the command line add --endpoint, for example sudo aftab ssl domain --endpoint vpn.example.com, or run the installer with AFTAB_SSL_ENDPOINT=yes.
Check, renew, remove
Section titled “Check, renew, remove”sudo aftab ssl status shows the certificate and whether it renews by itself. sudo aftab ssl renew renews it now. sudo aftab ssl remove goes back to plain HTTP.
What can go wrong
Section titled “What can go wrong”- “TCP port 80 is in use”. Another program holds the port. Stop it, try again, and start it afterwards.
- The check fails for a domain. The A record does not point to this server yet, Cloudflare’s proxy is on, or your provider’s firewall blocks port 80.
- It did not work. Nothing changed on the panel. Read the log shown, fix the cause and run the command again.