ItzCrazyKns / Perplexica

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

Use with service like ngrok for remote access from off LAN. #142

Open lafintiger opened 4 months ago

lafintiger commented 4 months ago

Is your feature request related to a problem? Please describe. Yes, I followed the instructions for lan access and that worked fine for accessing via lan. But when I use ngrok when I access the page the page loads but hangs on the spinning circle in the middle.

Describe the solution you'd like Instruction on how to get this awesome project accessible from off the lan. I would like to be at work and still access this from my server that I have running it.

Describe alternatives you've considered I tried ngrok and loclx. I only get the spinning circle.

Additional context None.

ItzCrazyKns commented 4 months ago

You just need to replace 127.0.0.1 in the docker compose file with the actual domain assigned to your backend and rebuild the images (making sure the previous ones are deleted).

delfireinoso commented 4 months ago

If anyone get this working should share

jonas-w commented 4 months ago

Basically @ItzCrazyKns posted the solution.

I don't know about ngrok, but likely your problem is that you are only forwarding the frontend and not the backend, I created this nginx config file for my host:

map $http_upgrade $connection_upgrade {
    default upgrade;
    ''      close;
}
upstream perplexica-frontend {
    server localhost:3000;
}
upstream perplexica-backend {
    server localhost:3001;
}

server {
    server_name <redacted>;
    listen 443 ssl http2;
    listen [::]:443 ssl http2;

    location / {
        proxy_pass http://perplexica-frontend;
        include proxy_params;
    }

    location /api {
        proxy_pass http://perplexica-backend/api;
        include proxy_params;
    }

    location /ws {
        proxy_pass http://perplexica-backend;
        include proxy_params;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection $connection_upgrade;
    }
}

This does the following: Proxy requests to the frontend, except /api and /ws which are proxied to the backend. And in the docker-compose.yml I set the following:

        - NEXT_PUBLIC_API_URL=https://<redacted>/api
        - NEXT_PUBLIC_WS_URL=wss://<redacted>/ws
delfireinoso commented 3 months ago

You can elaborate? Where you put this file, and wich is the name, in the compose tree under /Perplexica/ ? Or Nginx should be installed separated?

jonas-w commented 3 months ago

You can elaborate? Where you put this file, and wich is the name, in the compose tree under /Perplexica/ ? Or Nginx should be installed separated?

nginx is a reverse proxy like Caddy, Haproxy. Nginx just happens to be what I used. It is something extra you need to have, but If you have another reverse proxy already installed you can use that.

delfireinoso commented 3 months ago

nginx is a reverse proxy like Caddy, Haproxy. Nginx just happens to be what I used. It is something extra you need to have, but If you have another reverse proxy already installed you can use that.

I'll try to install Nginx and go this route, perhaps this time I'm lucky. we tried Cloudflare tunnels with not luck. It would be easier if Perplexica was designed to run remote.

delfireinoso commented 3 months ago

I'll try to use Caddy as I'm using zrok for the other projects. I'll try to translate to their syntax

one question: is the public name on Nginx? So I'll need to put this public name on the Perplexica compose file

Great to know