ItzCrazyKns / Perplexica

Perplexica is an AI-powered search engine. It is an Open source alternative to Perplexity AI
MIT License
13.03k stars 1.22k forks source link

How to use this service via HTTPS and custom domains #110

Closed zhuozhiyongde closed 3 months ago

zhuozhiyongde commented 3 months ago

As title, I hope to be able to run this service on my Ubuntu server and access it using a domain name, but my attempts have failed. I have carefully read through Networking.md, but it has not been effective for me.

Here is my config of backend:

location ^~ / {
    proxy_pass http://127.0.0.1:3001; 
    proxy_set_header Host $host; 
    proxy_set_header X-Real-IP $remote_addr; 
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 
    proxy_set_header REMOTE-HOST $remote_addr; 
    proxy_set_header Upgrade $http_upgrade; 
    proxy_set_header Connection "upgrade"; 
    proxy_set_header X-Forwarded-Proto $scheme; 
    proxy_http_version 1.1; 
    add_header X-Cache $upstream_cache_status; 
    add_header Strict-Transport-Security "max-age=31536000"; 

    # CORS
    add_header 'Access-Control-Allow-Origin' '*'; 
    add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
    add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
    add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range';
}

and docker-compose.yaml:

services:
  searxng:
    image: docker.io/searxng/searxng:latest
    volumes:
      - ./searxng:/etc/searxng:rw
    ports:
      - 4000:8080
    networks:
      - perplexica-network

  perplexica-backend:
    build:
      context: .
      dockerfile: backend.dockerfile
      args:
        - SEARXNG_API_URL=http://searxng:8080
    depends_on:
      - searxng
    ports:
      - 3001:3001
    networks:
      - perplexica-network

  perplexica-frontend:
    build:
      context: .
      dockerfile: app.dockerfile
      args:
        - NEXT_PUBLIC_API_URL=https://apidomain.of.myself/api
        - NEXT_PUBLIC_WS_URL=wss://apidomain.of.myself
    depends_on:
      - perplexica-backend
    ports:
      - 31337:3000
    networks:
      - perplexica-network

networks:
  perplexica-network:

Both the backend and frontend utilize a reverse proxy.

Error log:

Failed to load resource: the server responded with a status of 404 ()           https://apidomain.of.myself/library?_rsc=acgkz

WebSocket connection to 'wss://apidomain.of.myself/?chatModel=GPT-3.5+turbo&chatModelProvider=openai&embeddingModel=Text+embedding+3+small&embeddingModelProvider=openai' failed: The operation couldn’t be completed. Socket is not connected
zhuozhiyongde commented 3 months ago

I noticed https://github.com/ItzCrazyKns/Perplexica/issues/101#issuecomment-2105518810, it seems that external deployments are not supported at the moment.

Dalethium commented 3 months ago

https://github.com/ItzCrazyKns/Perplexica/issues/69#issuecomment-2103548702

This is the method I used, but please, again, be careful. You are exposing your OpenAPI keys along with any other config and the entire system to the web without any authentication. Be sure to put it behind some sort of firewall, entirely blocking it out without a login, such as authelia.

ItzCrazyKns commented 3 months ago

Unfortunately we don't provide support to deploy it / serve it over HTTPS or on some server rather its installation. You can rather use Repocloud or use the steps recommended by everyone. Its pretty straightforward to host it.