silverwind / droppy

**ARCHIVED** Self-hosted file storage
BSD 2-Clause "Simplified" License
1.62k stars 195 forks source link

Redirect with Nginx #397

Open SergioSaar96 opened 4 years ago

SergioSaar96 commented 4 years ago

Hi, I have configured my nginx server as follows to access droppy via http://localhost/droppy

location /droppy { rewrite ^/droppy(.*) /$1 break; proxy_pass "http://localhost:8989"; }

And when I access through /droppy I get the application without the block to enter username and password, I only get the black background, and this is the result I get in the console:

GET http://localhost/!/res/client.js net::ERR_ABORTED 404 (Not Found) Refused to apply style from 'http://localhost/!/res/style.css' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled. GET http://localhost/!/res/sprites.png net::ERR_ABORTED 404 (Not Found)

when I access by port this does not happen and I can use droppy normally.

Thanks for the help.

aidenmadaffri commented 4 years ago

I am experiencing the same problem.

GetLiberated commented 4 years ago

Any update?

SergioSaar96 commented 4 years ago

@GetLiberated Unfortunatelly no

GetLiberated commented 4 years ago

I found it, try this:

location /droppy/ {
      proxy_pass http://localhost:8989/;
      ...
}

Turn out the '/' at the end is really important.

SergioSaar96 commented 4 years ago

@GetLiberated like you say the '/' is really important, i have a lot of problems because i'm using SSL too, but here is my actually working configuration:



       #MYAPP
    upstream app_portfolio {
        server 127.0.0.1:3000;
    }

    #DROPPY
    upstream app_droppy {
        server 127.0.0.1:8989;
    }

    #HTTP REDIRECT TO HTTPS
    server {
        listen 0.0.0.0:80;
        server_name yourservername.es;
        server_tokens off;
        return 301 https://$host$request_uri;
    }

    #HTTPS SERVER FOR MY APPS
    server {
        listen 443 ssl;
        ssl_certificate      /etc/nginx/yourcertificate_ssl_certificate.cer;
        ssl_certificate_key  /etc/nginx/yourkey_private_key.key;

        server_name yourservername.es;

        location / {
            proxy_ssl_server_name on;
            proxy_pass http://app_portfolio;
            proxy_redirect off;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
            proxy_set_header Host $host;
        }

        location /droppy/ {
            rewrite /droppy/(.*)$ /$1 break;

            proxy_ssl_server_name on;
            proxy_pass http://app_droppy;
            proxy_redirect off;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
            proxy_set_header Host $host;
        }
    }