andrii-kryvoviaz / slink

Self-hosted image sharing service.
GNU Affero General Public License v3.0
306 stars 9 forks source link

Redirected to https://slink.mydomain.com/profile #15

Open nothing2obvi opened 6 months ago

nothing2obvi commented 6 months ago

On the "Upload History" page, when I click on the link above "Download" or on the image itself (on the left), I get redirected to https://slink.mydomain.com/profile instead. However, if I hold down the Command button and click on these links to open in a new tab, they open https://slink.mydomain.com/info/

The same thing happens when I drag and drop an image into the uploader. I am immediately redirected to https://slink.mydomain.com/profile.

andrii-kryvoviaz commented 6 months ago

Hmm, that is interesting. Could you drop a few words about your infrastructure, which reverse proxy you use and which configuration it has?

nothing2obvi commented 6 months ago

Sure, thanks for the reply. I'm using Slink via Docker and using SWAG (Nginx) as my reverse proxy.

Here is my docker-compose.yml for Slink:

---
services:
  slink:
    image: anirdev/slink:latest
    container_name: slink
    environment:
      # Your application hostname
      - ORIGIN=https://slink.mydomain.com
      # Require user approval before they can upload images
      - USER_APPROVAL_REQUIRED=true
      # Maximum image size allowed to be uploaded (no more than 50M)
      - IMAGE_MAX_SIZE=50M
      # Storage provider to use. 
      # Available options are local and smb
      - STORAGE_PROVIDER=local
    volumes:
      # Persist the database
      - /Users/username/Docker/slink/var/data:/app/var/data
      # Persist the uploaded images
      - /Users/username/Docker/slink/images:/app/slink/images
    ports:
      # Expose the application on port 3000
      - "3700:3000"
    labels:
      - "com.centurylinklabs.watchtower.enable=true"
networks:
  default:
    name: lsio
    external: true

And here is my slink.subdomain.conf file. The only things changed from the template are that I changed the container name to slink and the port to 3000. Btw, the $upstream_proto is http because that's how it is for all my other subdomain.conf files, like Jellyfin, Audiobookshelf, Kavita, Immich, etc:

## Version 2023/05/31
# REMOVE THIS LINE BEFORE SUBMITTING: The structure of the file (all of the existing lines) should be kept as close as possible to this template.
# REMOVE THIS LINE BEFORE SUBMITTING: Look through this file for <tags> and replace them. Review other sample files to see how things are done.
# REMOVE THIS LINE BEFORE SUBMITTING: The comment lines at the top of the file (below this line) should explain any prerequisites for using the proxy such as DNS or app settings.
# make sure that your slink container is named slink
# make sure that your dns has a cname set for slink

server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;

    server_name slink.*;

    include /config/nginx/ssl.conf;

    client_max_body_size 0;

    # enable for ldap auth (requires ldap-location.conf in the location block)
    #include /config/nginx/ldap-server.conf;

    # enable for Authelia (requires authelia-location.conf in the location block)
    #include /config/nginx/authelia-server.conf;

    # enable for Authentik (requires authentik-location.conf in the location block)
    #include /config/nginx/authentik-server.conf;

    location / {
        # enable the next two lines for http auth
        #auth_basic "Restricted";
        #auth_basic_user_file /config/nginx/.htpasswd;

        # enable for ldap auth (requires ldap-server.conf in the server block)
        #include /config/nginx/ldap-location.conf;

        # enable for Authelia (requires authelia-server.conf in the server block)
        #include /config/nginx/authelia-location.conf;

        # enable for Authentik (requires authentik-server.conf in the server block)
        #include /config/nginx/authentik-location.conf;

        include /config/nginx/proxy.conf;
        include /config/nginx/resolver.conf;
        set $upstream_app slink;
        set $upstream_port 3000;
        set $upstream_proto http;
        proxy_pass $upstream_proto://$upstream_app:$upstream_port;

        # REMOVE THIS LINE BEFORE SUBMITTING: Additional proxy settings such as headers go below this line, leave the blank line above.
    }

    # REMOVE THIS LINE BEFORE SUBMITTING: Some proxies require one or more additional location blocks for things like API or RPC endpoints.
    # REMOVE THIS LINE BEFORE SUBMITTING: If the proxy you are making a sample for does not require an additional location block please remove the commented out section below.
    # location ~ (/slink)?/api {
    #     include /config/nginx/proxy.conf;
    #     include /config/nginx/resolver.conf;
    #     set $upstream_app slink;
    #     set $upstream_port 3000;
    #     set $upstream_proto http;
    #     proxy_pass $upstream_proto://$upstream_app:$upstream_port;
    #
    #     # REMOVE THIS LINE BEFORE SUBMITTING: Additional proxy settings such as headers go below this line, leave the blank line above.
    # }
}
andrii-kryvoviaz commented 6 months ago

Your config seems good to me, there’s nothing unusual. It should definitely work. Today I released a little patch, let me know if it helps. If not, I would ask about your browser.

nothing2obvi commented 6 months ago

Thanks for following up. I tested on v1.0.1 and it still redirects. I am using Opera latest version (109.0.5097.45).

andrii-kryvoviaz commented 6 months ago

Thank you for the update. I tried to reproduce the issue, but with no results. Later, I will try to debug it a little bit more.

nothing2obvi commented 6 months ago

Sounds good. Thanks again. I just tested it on Safari and I don't seem to have any issues. Maybe it's a weird quirk for Opera?

andrii-kryvoviaz commented 6 months ago

I've tried Opera and it seems to be working as expected. But yeah it could be something related to Opera that I am missing.