Skip to content

bobycx/bobVPN2_RESTAPI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

How I deployed on my Ubuntu server

Set up NGINX + Firewall rules

  1. apt install nginx
  2. vim /etc/nginx/sites-enabled/fastapi_nginx
server {
        listen 80;
        server_name MYSERVERIP;
        location / {
                proxy_pass http://127.0.0.1:8003;
        }
}
  1. sudo ufw allow 'Nginx HTTP'
  2. sudo ufw enable
  3. sudo service nginx restart

Prep the config database directory

  1. mkdir ~/ovpn-client-configs/

Start the API service

  1. sudo chmod +x ./generate_config
  2. uvicorn bobvpnAPI:app --port 8003

or with pm2: pm2 start "uvicorn bobvpnAPI:app --port 8003" --name bobapi

API Reference

Generate Config [POST]

Generates an OpenVPN config file for a client.

  • URL: /generate_config
  • Method: POST
  • Headers:
    • Content-Type: application/json
    • Authorization: Bearer {api-key}
  • Parameters:
    • client_name (string): The name of the client for whom to generate the config file.
  • Response:
    • 200 OK:
      • Content-Type: application/octet-stream
      • Body: The generated OpenVPN config file.
    • 401 Unauthorized:
      • Body: Invalid or missing API Key.

Example

POST /generate_config HTTP/1.1
Host: localhost:8000
Content-Type: application/json
Authorization: Bearer BOBVPNISTHEBEST

{
  "client_name": "john_doe"
}

Response:

HTTP/1.1 200 OK
Content-Type: application/octet-stream
Content-Disposition: attachment; filename="john_doe.ovpn"

<contents of the generated OpenVPN config file>

or

HTTP/1.1 401 Unauthorized
Content-Type: application/json

{
  "detail": "Invalid or missing API Key"
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published