Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Config: Support non-root site URL for shared domains #425

Closed
lolrofllol opened this issue Jul 26, 2020 · 21 comments
Closed

Config: Support non-root site URL for shared domains #425

lolrofllol opened this issue Jul 26, 2020 · 21 comments
Assignees
Labels
idea Feedback wanted / feature request released Available in the stable release

Comments

@lolrofllol
Copy link

Hi,

I am running Photoprism behind Traefik directly on subdomain.domain.com. Everything is working fine. But when I try to run it at some non-root path, let's say /photoprism, it only shows only the big photoprism logo instead of the login form.

I tried to use the StripPrefix Middleware of Traefik which removes the /photoprism part of the URL. Still not working.

Has anyone suggestions to get this working at some non-root URL Path?

Thanks in advance

@lastzero
Copy link
Member

That's not supported at the moment. Since https certs and sub domains are free nowadays, why use a path? It's also more complicated in terms of security and browser storage as AFAIK you share one local storage per (sub) domain. That can have all sorts of side effects.

@lastzero lastzero added declined Cannot be merged / implemented at this time idea Feedback wanted / feature request labels Jul 28, 2020
@sandreas
Copy link

Since https certs and sub domains are free nowadays, why use a path?

I understand this argument for classic hosting... but depending on the infrastructure unfortunately sometimes this is just not possible. In my case I'm using DynDNS where multiple subdomains are not supported and I'm reverse proxying multiple services on a single dyndns domain (/gitea, /nextcloud, etc.).

It would be awesome if either the existing setting PHOTOPRISM_SITE_URL having a subdirectory would take effect or a new setting like ROOT_URL would be supported (e.g. like gitea does).

Just my two cents.

@lastzero
Copy link
Member

Dyndns wildcard domains are possible, for example with a free DigitalOcean account. Also supported by let's encrypt.

@sandreas
Copy link

Dyndns wildcard domains are possible, for example with a free DigitalOcean account

Thank you for the quick response. Well, I'm not saying that it is impossible to solve my specific problems and I really appreciate your work. But I just would like to express, that there are definitely use cases where it would be at least more convinient to have an option for subdirectory configuration and I would surely like to vote up this issue.

Photoprism is a pretty big project, otherwise I would have tried to create a pull request on my own :-)

@lastzero
Copy link
Member

It's a ton of work, changing the domain / cert config is definitely easier meanwhile. Also more secure.

@libook
Copy link

libook commented May 22, 2021

Thank all contributors to this project.

I have ton of website are hosted in home LAN. Such as Gogs, Vaultwarden, OMV, Portainer and so on.
It is a hard work to keep domains and certificates working for each one.

It seems that subpath/subdirectory may cure my pain. Luckily other projects support this, except docker registry.

I understand that supporting subpath/subdirectory means changing whole architecture of the front-end.

But I also hope it will come true.

@sandreas
Copy link

Maybe using base would just be enough... but I'm afraid it's not that simple...

<base href="/subdir/">

https://developer.mozilla.org/de/docs/Web/HTML/Element/base

@lastzero
Copy link
Member

No, it's not that simple.

lastzero added a commit that referenced this issue Jul 5, 2021
@lastzero lastzero added please-test Ready for acceptance test and removed declined Cannot be merged / implemented at this time unfunded labels Jul 5, 2021
@lastzero lastzero self-assigned this Jul 5, 2021
@lastzero lastzero changed the title Photoprism behind Reverse Proxy on non-root Path Config: Support non-root site URL for shared domains Jul 8, 2021
@lastzero
Copy link
Member

lastzero commented Jul 8, 2021

Should would with our latest Development Preview when you configure a non-root site URL in docker-compose.yml. Feedback welcome!

@sandreas
Copy link

sandreas commented Jul 8, 2021

@lastzero Awesome news... thank you.

@lastzero lastzero removed the please-test Ready for acceptance test label Jul 13, 2021
lastzero added a commit that referenced this issue Jul 13, 2021
@Schroedingers-Cat
Copy link

Should would with our latest Development Preview when you configure a non-root site URL in docker-compose.yml. Feedback welcome!

@lastzero still all I get is the PhotoPrism logo only, no login or any functional UI on the webpage. Here's the relevant part from my docker-compose:

services:
  photoprism:
    # Use photoprism/photoprism:preview instead for testing preview builds:
    image: photoprism/photoprism:preview
    PHOTOPRISM_SITE_URL: "https://myserverdomain.de/photoprism/"

And the settings of my nginx reverse proxy:

# Photoprism
location /photoprism {
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $host;

    proxy_pass http://localhost:2342;
    rewrite /photoprism/(.*) /$1 break;
    rewrite ^/photoprism$ /photoprism/ permanent;

    proxy_buffering off;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
}

has the feature been disabled or is there anything I'm missing to enable this?

@lastzero
Copy link
Member

@Schroedingers-Cat Think it's caused by this rewrite rule:

rewrite /photoprism/(.*) /$1 break;

@SpikedBlue
Copy link

Tested this feature in the development preview.
Found a problem with share links.

Copied link: https://.../photoprism/s/wecj8ms5k0/test
After entering the link, it gets redirected to: https://.../s/wecj8ms5k0/aqy9fch8tu58zyti
The redirect removes the "photoprism" subfolder.
Manually adding it back works. i.e. https://.../photoprism/s/wecj8ms5k0/aqy9fch8tu58zyti

Would this be caused by the internal photoprism link redirects? Doesn't appear to be caused by SWAG's config.

@graciousgrey graciousgrey added the released Available in the stable release label Sep 26, 2021
@piyo
Copy link

piyo commented Oct 3, 2021

For Apache 2.4 reverse proxy with non-root site url, I was successful with this config.

docker-compose.yml

PHOTOPRISM_SITE_URL: "https://www.example.com/photoprism/"

/etc/apache2/sites-enabled/reverse-proxy-for-photoprism.conf

# Optional set up for SSL/TLS not explained.
ProxyRequests Off
<IfModule mod_proxy_wstunnel.c>
# PhotoPrism uses the non-root path in PHOTOPRISM_SITE_URL, so retain it in the second parameter
ProxyPass        /photoprism/api/v1/ws ws://127.0.0.1:2342/photoprism/api/v1/ws
ProxyPassReverse /photoprism/api/v1/ws ws://127.0.0.1:2342/photoprism/api/v1/ws
ProxyPass        /photoprism/          http://127.0.0.1:2342/photoprism/
ProxyPassReverse /photoprism/          http://127.0.0.1:2342/photoprism/        
</IfModule>

@Tralbi
Copy link

Tralbi commented Oct 8, 2021

With
PHOTOPRISM_SITE_URL: "https://www.example.com/prism/"
and apche ProxyPass/ProxyReverse browser doesn't receive app.js (and manifest.json?) correctly
and gives me
error
Like it parses html file as js file.
pointing browser directly to ip:2342/prism works correctly

<Location /prism>
<IfModule mod_proxy_wstunnel.c>
ProxyPass        http://127.0.0.1:2342/prism/
ProxyPassReverse http://127.0.0.1:2342/prism/
</IfModule>
</Location>


<Location /prism/api/v1/ws>
<IfModule mod_proxy_wstunnel.c>
ProxyPass        ws://127.0.0.1:2342/prism/api/v1/ws
ProxyPassReverse ws://127.0.0.1:2342/prism/api/v1/ws
</IfModule>
</Location>

what am I missing?

@Tralbi
Copy link

Tralbi commented Oct 8, 2021

using /prism/api/v1/ws/ solved my issue

<Location /prism>
<IfModule mod_proxy_wstunnel.c>
ProxyPass        http://127.0.0.1:2342/prism
ProxyPassReverse http://127.0.0.1:2342/prism
</IfModule>
</Location>


<Location /prism/api/v1/ws/>
<IfModule mod_proxy_wstunnel.c>
ProxyPass        ws://127.0.0.1:2342/prism/api/v1/ws/
ProxyPassReverse ws://127.0.0.1:2342/prism/api/v1/ws/
</IfModule>
</Location>

@Slevin7
Copy link

Slevin7 commented Jan 10, 2022

Should would with our latest Development Preview when you configure a non-root site URL in docker-compose.yml. Feedback welcome!

@lastzero still all I get is the PhotoPrism logo only, no login or any functional UI on the webpage. Here's the relevant part from my docker-compose:

services:
  photoprism:
    # Use photoprism/photoprism:preview instead for testing preview builds:
    image: photoprism/photoprism:preview
    PHOTOPRISM_SITE_URL: "https://myserverdomain.de/photoprism/"

And the settings of my nginx reverse proxy:

# Photoprism
location /photoprism {
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $host;

    proxy_pass http://localhost:2342;
    rewrite /photoprism/(.*) /$1 break;
    rewrite ^/photoprism$ /photoprism/ permanent;

    proxy_buffering off;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
}

has the feature been disabled or is there anything I'm missing to enable this?

may I ask how your config looks like now?
I can't get that behind the nginx proxy to work

@rezzalex
Copy link

rezzalex commented Jun 2, 2022

Hello everyone,

@Tralbi or @Slevin7 , would you know the right settings to apply in NGINX to make this non-root location works?

thanks

@thisisbinod
Copy link

This works for me on Nginx

docker-compose.yml
PHOTOPRISM_SITE_URL: "http://localhost:2342/photoprism/"

nginx

    location /photoprism/ {
        proxy_pass http://<YOUR-LOCAL-IP>/photoprism/;
        proxy_set_header  Host $host;
        proxy_set_header  X-Real-IP $remote_addr;
        proxy_set_header  X-Forwarded-Proto https;
        proxy_set_header  X-Forwarded-For $remote_addr;
        proxy_set_header  X-Forwarded-Host $remote_addr;
    }

@sunny5055
Copy link

This works for me on Nginx

docker-compose.yml PHOTOPRISM_SITE_URL: "http://localhost:2342/photoprism/"

nginx

    location /photoprism/ {
        proxy_pass http://<YOUR-LOCAL-IP>/photoprism/;
        proxy_set_header  Host $host;
        proxy_set_header  X-Real-IP $remote_addr;
        proxy_set_header  X-Forwarded-Proto https;
        proxy_set_header  X-Forwarded-For $remote_addr;
        proxy_set_header  X-Forwarded-Host $remote_addr;
    }

Doesnt work. Any way to check on this ? Havent been successful so far on this.

@lastzero
Copy link
Member

lastzero commented Aug 6, 2022

Please don't use GitHub Issues for discussions and support questions. Thank you! ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
idea Feedback wanted / feature request released Available in the stable release
Projects
Status: Release 🌈
Development

No branches or pull requests