Dan6erbond / share-me

An image and video hosting platform for your server, with rich embed support and API.
https://dan6erbond.github.io/share-me/
MIT License
145 stars 10 forks source link

Setting up Reverse Proxy with SWAG? #48

Open beboprocky opened 8 months ago

beboprocky commented 8 months ago

Example: https://shareme.domain.com

Setup (using *.domain.com as an example): Docker Compose frontend: environment: POCKETBASE_URL: https://shareme-pb.domain.com

I then go to shareme-pb.domain.com/_/ I create an admin account. I create a user account. I go to Settings > Application > and set the following: Application name: shareme Application url: https://shareme.domain.com (same url as above but without "-pb")

Both domains work. But I am unable to login or sign up for a new account on the front end. Clicking "Login" does nothing. Clicking "Sign Up" gives me a 500 error.

I'm a little confused on the setup at this point.. The documentation says to forward "/api and /_ to the PocketBase backend" and "the rest of the traffic including /_next to the frontend". I saw in a Reddit post this possible to do with using subdomains, but I'm not sure what subdomains should be pointed to which domains or IP addresses. I don't believe SWAG can forward paths, so subdomains might be my only route.

Also, would the backend in this case be "shareme-pb.domain.com" or would I need to forward api and /_ to something else?

Thank you for the help if at all possible. I'm a self-host hobbyist so a few concepts do go over my head. I was able to get it working locally without a reverse proxy and this seems to be exactly what I was looking for. I appreciate the hard work that's gone into this project. It was definitely needed in the self-hosting space.

naanlizard commented 3 months ago

SWAG can indeed forward paths, but I'm not sure about support for subfolders (as they're typically called) in shareme. Unfortunately the dev is pretty much AFK on this program, but it works pretty well anyway.

The issue you have with the frontend suggests the frontend isn't talking to the backend for whatever reason. I'm not sure exactly how the config is supposed to work, but this is what I have for mine that works

  shareme-server:
    container_name: shareme-server
    hostname: shareme-server
    image: ghcr.io/dan6erbond/share-me-server
    volumes:
      - ./shareme/pb_data:/pb/pb_data
    restart: unless-stopped

  shareme-frontend:
    container_name: shareme-frontend
    hostname: shareme-frontend
    image: ghcr.io/dan6erbond/share-me-frontend
    environment:
      POCKETBASE_URL: https://images.hostname.com
      SIGNUP_ENABLED: 0
    restart: unless-stopped

And in my docker-swag images.subdomain.conf

server {
    listen 443 ssl;

    server_name images.hostname.com;

    include /config/nginx/ssl.conf;

    client_max_body_size 0;

    location / {

        include /config/nginx/proxy.conf;

        proxy_pass http://<frontendIP>:3000;
    }

    location /api {

        include /config/nginx/proxy.conf;

        proxy_pass http://<pocketbaseIP>:8080;
    }

    location /_/ {

        include /config/nginx/proxy.conf;

        proxy_pass http://<pocketbaseIP>:8080;
    }

}