glanceapp / glance

A self-hosted dashboard that puts all your feeds in one place
GNU Affero General Public License v3.0
8.56k stars 297 forks source link

feat: serving behind reverse proxy #167

Closed CremaLuca closed 3 months ago

CremaLuca commented 4 months ago

Hi, I quickly added support for hosting behind a reverse proxy #125 (nginx).

Served urls have not been changed as the reverse proxy will hide the base url in the http request (site.com/glance/ will be received as /), only links have changed.

Base url can be specified in the configuration under Server:

server:
  base-url: /glance

Note that it must begin with a slash / to work properly.

Tested with go run . and docker container, currently running in my home server setup.

Feel free to change whatever you need.

TODO

manifest.json still contains /static/app-icon.png which won't resolve properly, probabily will need to template the file using go.

Example

My current setup is the following:

nginx.conf

location /glance/ {
    proxy_pass http://127.0.0.1:8080/;

    proxy_set_header X-Forwarded-For $remote_addr;
    proxy_set_header X-Forwarded-Host $http_host;
    proxy_set_header Host $host;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "Upgrade";
}

docker-compose.yml

services:
  glance:
    image: MY_CUSTOM_NAME/glance
    volumes:
      - ./glance.yml:/app/glance.yml
      - /etc/timezone:/etc/timezone:ro
      - /etc/localtime:/etc/localtime:ro
    ports:
      - 8080:8080
    restart: unless-stopped

glance.yml

server:
  base-url: /glance
svilenmarkov commented 3 months ago

Thanks for contributing!