developersdigest / llm-answer-engine

Build a Perplexity-Inspired Answer Engine Using Next.js, Groq, Llama-3, Langchain, OpenAI, Upstash, Brave & Serper
https://developersdigest.tech
MIT License
4.64k stars 739 forks source link

run on vps and domain #51

Open xiongvalerio opened 5 months ago

xiongvalerio commented 5 months ago

how to run this,on the vps and connect a domain?

AmoghSaxena commented 2 months ago

You Can setup a reverse proxy or port forwading or VPN Tunnel Like cloudflare

Set Up Nginx Reverse Proxy for Webserver WebUI

A reverse proxy is a proxy for another web server, in this case the WebUI. Setting up Nginx reverse proxy makes it easy to enable HTTPS protocol.  Install Nginx on Ubuntu 18.04.

sudo apt install nginx

Start Nginx.

sudo systemctl start nginx

Then create a Nginx server block file for WebUI.

sudo nano /etc/nginx/conf.d/qbittorrent-webui.conf

Copy and paste the following texts into the file. Replace the red-colored text with your own domain name and the IP address of your Ubuntu server. You should also set the A record for your domain name. If you don’t have a domain name yet, then I recommend buying domain name from Namecheap because their price is lower than GoDaddy and they give you whois privacy protection free of charge.

server {
  listen 80;
  server_name name.your-domain.com;

  access_log /var/log/nginx/name.your-domain.com.access;
  error_log /var/log/nginx/name.your-domain.com.error;

  location / {
    proxy_pass              http://your-server-ip:8080/;
    proxy_set_header        X-Forwarded-Host        $server_name:$server_port;
    proxy_hide_header       Referer;
    proxy_hide_header       Origin;
    proxy_set_header        Referer                 '';
    proxy_set_header        Origin                  '';
    add_header              X-Frame-Options         "SAMEORIGIN";
  }
}

Save and close the file. Then test Nginx configuration.

sudo nginx -t

If the test is successful, reload Nginx

sudo systemctl reload nginx

Now in your router, forward HTTP request (port 80) to the IP address of your Ubuntu server. After that, you can access WebUI via your domain name (name.your-domain.com).

Note: If your ISP gives you a NAT-ed IP address, i.e. not a public IP address, then port forwarding won’t work. Instead, you need to use PageKite to expose local web server to the Internet.

Enable HTTPS to Encrypt Communications

To secure the Web UI, you can install a free TLS certificate issued by Let’s Encrypt. First you need to install the Let’s Encrypt client (certbot) on Ubuntu 18.04 server.

sudo apt install software-properties-common

sudo add-apt-repository ppa:certbot/certbot

sudo apt install certbot python3-certbot-nginx

Python3-certbot-nginx is the Certbot Nginx plugin. After they are installed, run the following command to automatically obtain and install Let’s Encrypt certificate.

sudo certbot --nginx --redirect --agree-tos --hsts --staple-ocsp --email your-email-address -d name.your-domain.com

Once that’s done, refresh the Web UI. It will be automatically redirected to HTTPS connection.

image

In my case I used CloudFlare for VPN Tunnel

image