psi-4ward / psitransfer

Simple open source self-hosted file sharing solution.
BSD 2-Clause "Simplified" License
1.48k stars 216 forks source link

Issue with reverse proxy #171

Open dem0ngo opened 3 years ago

dem0ngo commented 3 years ago

I am trying to set up Psitransfer for use with nginx through reverse proxy, but I can't seem to get it right. I used the example here as well as the template for subfolder .conf files that SWAG shows and am not having luck. This is what the .conf looks like so far:

location /psitransfer {
    return 301 $scheme://$host/psitransfer/;
}

location ^~ /psitransfer/ {
    include /config/nginx/proxy.conf;
    resolver 127.0.0.11 valid=30s;
    set $upstream_app psitransfer;
    set $upstream_port 3000;
    set $upstream_proto http;
    proxy_pass $upstream_proto://$upstream_app:$upstream_port;

    proxy_buffering off;
    proxy_request_buffering off;      # needs nginx version >= 1.7.11
    proxy_set_header Host $http_host;

}

When I load the site through my reverse proxy I can see the logo, but that's about it and clicking any links doesn't do anything. The console shows some 404 errors when trying to access psitransfer.

What is wrong with my location block?

UPDATE: Do I need to set a base url somehow? I tried using "uploadAppPath", but nothing changed.

image_2021-05-07_213055 image_2021-05-09_131139

dem0ngo commented 3 years ago

Okay, so I now have it working sort of. I did need to add a base url which was done by adding it to the environment section of my compose script like so: PSITRANSFER_BASE_URL="/psitransfer"

Now the issue is that it looks awful. It functions, but the CSS/formatting is not working. The logo is massive at the top and then the upload section is all crammed in at the bottom. What else am I missing in order to get this to look like it should?

image_2021-05-09_133356 image_2021-05-09_134503

dem0ngo commented 3 years ago

Okay I finally have it working, but not with a subfolder. The only way I could access it and have the CSS work was by using a subdomain instead of a subfolder. Will support for subfolders be added eventually?

thehijacker commented 3 years ago

Hello,

For me this is working fine.

    location ^~ /psitransfer/ {
        proxy_pass http://127.0.0.1:3993;
        proxy_buffering off;
        proxy_request_buffering off;
        proxy_set_header Host $http_host;
    }

Using systemd script to autostart it:

[Unit]
Description=PsiTransfer
Documentation=https://github.com/psi-4ward/psitransfer
After=network.target

[Service]
Type=simple
User=psitransfer
Restart=on-failure

Environment=NODE_ENV=production
Environment=PSITRANSFER_UPLOAD_DIR=/mnt/usb_1/Upload
Environment=PSITRANSFER_ADMIN_PASS=pass1
Environment=PSITRANSFER_UPLOAD_PASS=pass2
Environment=PSITRANSFER_PORT=31133
Environment=PSITRANSFER_BASE_URL=/psitransfer

WorkingDirectory=/opt/psitransfer
ExecStart=/usr/bin/node app.js

[Install]
WantedBy=multi-user.target

GUI loads fine. Upload is working. So does download via shared link. Using latest version as of today (2.0.1). Installed it with this instructions from docs:

https://github.com/psi-4ward/psitransfer/blob/master/docs/deployment-systemd.md

Works great. Finally a simple self hosted file service.