Openvpn

Before start, set local SSH keys

$ ssh-keygen -t ed25519 -C 'sysadm' -f ~/.ssh/sysadm_ed25519
$ ssh-keygen -t rsa -b 4096 -C 'sysadm' -f ~/.ssh/sysadm_rsa

How to SSH to server?

$ ssh root@<server-ip>

Start setting vpn

Before start assign SERVER_IPV4 to your server ip in "openvpn_install.sh" and give permission to "setup.sh" with following command:

$ chmod +x setup.sh

Now, SSH to server and run script:

$ ./setup.sh

Once Paste the cryptic text from your local SSH public key: appears on screen, copy and paste public SSH key to it (for example, in my case: cat /home/kerim/.ssh/sysadm_ed25519.pub) and Ctrl+D to move forward.

Later, SSH to server once again and run other script:

$ ./openvpn.sh

Create user account with some name

$ ./openvpn_adduser.sh <username>

Delete user account in case of you need:

$ ./openvpn_removeuser.sh

Check whether vpn user has been created:

$ ls /opt/profiles/

If yes, exit from server and pull created openvpn account to your local machine with SCP protocol:

$ scp -P 2219 sysadm@<server-ip>:/opt/profiles/<username>.ovpn ~/Desktop/

Now you can view your created openvpn user in your Desktop, congrats!

Nginx reverse proxy

First install nginx:

$ sudo apt install nginx

Open nginx document:

$ sudo nano /etc/nginx/sites-available/default

Redirect requests to your preferred server, e.g., add

return 301 https://www.google.com/; after

listen 80 default_server;
listen [::]:80 default_server;

Save and restart nginx:

$ sudo systemctl status nginx

You might also need to allow traffic on port 80 in your firewall rules. In case of nftables add

tcp dport 80 counter accept

near

tcp dport 2219 counter accept
tcp dport 21 counter accept

in /etc/nftables.conf.

Finally restart nftables:

$ sudo systemctl restart nftables

Test if visiting your server IP in your browser redirects HTTP requests.

Reference

Original link