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

Add a URL Base option #72

Closed
Logvin opened this issue Mar 22, 2016 · 118 comments
Closed

Add a URL Base option #72

Logvin opened this issue Mar 22, 2016 · 118 comments
Labels

Comments

@Logvin
Copy link

Logvin commented Mar 22, 2016

Sonarr and CouchPotato both have options for URL Bases. I'm using a NGINX reverse proxy. When I go to mydomain.com/requests it immediately changes the URL to mydomain.com/userlogin and gives me a 404 page. I'm not 100% sure that a URL Base is what we need to resolve my issues, but it appears it is something this app needs.

@tidusjar
Copy link
Member

I've done all the work on this and it will be in the next release.

So, since it's redirecting you, where would you expect it to go? mydomain.com/requests/userlogin?

@tidusjar
Copy link
Member

@Logvin Does this link help? https://github.com/NancyFx/Nancy/wiki/Hosting-Nancy-with-Nginx-on-Ubuntu#install-nginx

PlexRequests.Net is using the Nancy framework.

@mescon
Copy link

mescon commented Mar 23, 2016

I'm waiting for this until I migrate from the meteor version :-)

@tidusjar
Copy link
Member

@mescon do you have the same issue as @Logvin ?

@mescon
Copy link

mescon commented Mar 23, 2016

No, that hasn't been verified, but I do run all of my services behind an nginx reverse proxy and decided to hold off on moving to PR.Net until I saw that this issue was resolved.
I've been banging my head on this on several other applications - nzbhydra, couchpotato, pydio, headphones and so on... some were fixed by the authors, others I've patched myself, though I don't know the first thing about .NET development, so I hoped to just see this issue closed before trying anything in mono :-)

@tidusjar
Copy link
Member

@mescon What does the meteor version do to fix this issue?

@mescon
Copy link

mescon commented Mar 23, 2016

I run it with:
ROOT_URL=http://localhost/requests meteor
... as opposed to:
meteor

@tidusjar
Copy link
Member

So then everything runs under /requests e.g. /requests/admin ?

@mescon
Copy link

mescon commented Mar 23, 2016

yeah exactly..., so for my nginx I just do (proxy-control.conf is just some authentication and other stuff)

location /requests {
        proxy_pass http://localhost:3000/requests;
        include         proxy/proxy-control.conf;
}

@mescon
Copy link

mescon commented Mar 23, 2016

The important thing is to make sure all clickable items/urls/images/css/js are all with relative paths and NOT absolute paths ../images/bla.png instead of /images/bla.png as that would lead to http://whatever.com/images/bla.png when it is supposed to be http://whatever.com/requests/images/bla.png

@Logvin
Copy link
Author

Logvin commented Mar 24, 2016

The URL did not help, unfortunately. I have NGINX set up and working with CouchPotato and Sonarr no problem.

I think @mescon has it right... you are using absolute paths, not relative paths.

@tidusjar
Copy link
Member

I'm going to create a separate branch to be able to test the fix for this (I do not want to make the changes in the main code yet). Once this is complete are you happy to try it out?

@tidusjar
Copy link
Member

Here is the custom build that has attempted to fix this, please let me know how you get on. If this works I will merge it into the mail codebase.

https://ci.appveyor.com/project/tidusjar/requestplex/build/1.4.50/artifacts

@ruricu
Copy link

ruricu commented Mar 24, 2016

I'm testing 1.4.54 on this branch; 1.4.50 did not appear to have any changes supporting redirects, unless I'm mistaken.

When I launched the app, the console displays "Request Plex is running on the following: http://+:3579/"

I assume this string was changed from previous versions to allow subdir support for Plex Requests itself, but there is no setting in the administration pane, and I could not find a configuration file to specify this. Where do we set the base path/subdir for Plex Requests itself?

One note on usability: When configuring Couchpotato with the IP/port correct, but the subdirectory not correct, the error supplied is:
Could not connect to CouchPotato, please check your settings. Exception Message: 'doctype' is an unexpected token. The expected token is 'DOCTYPE'. Line 2, position 3.
Perhaps this could be handled more eloquently.

After correcting this, CouchPotato worked fine.

Sonarr, on the other hand claimed to connect successfully with or without the SubDir. This is because Sonarr builds in a redirect at /, I guess. Neat. I thought I was still having issues after this, but it turns out my "Root save directory" was not a valid path. "Something went wrong"; perhaps, at very least, this path should be tested for validity to some degree. Once this was corrected, Sonarr worked correctly with/without the subdirectory specified.

@tidusjar
Copy link
Member

Hello, the build 1.4.54 is the latest Development branch and is not stable. The build I provided above has specific changes to how we are redirecting content and hopefully will get around the subdir issue.
I am hoping this build will fix the issue posted here: https://ci.appveyor.com/project/tidusjar/requestplex/build/1.4.50/artifacts

The couchpotato error is difficult to handle as it can vary, the reason it complains about the doctype is because it's attempting to parse JSON but it's got HTML back as it's not the correct endpoint.

I agree there could be better error handling with the Something went wrong and we could test the root save directory.

@Logvin
Copy link
Author

Logvin commented Mar 24, 2016

I should have some time tonight (10 hours from this post) to test this out. I'll install the test build and provide feedback.

@tidusjar
Copy link
Member

@Logvin Thanks. That would help a lot.

@ruricu
Copy link

ruricu commented Mar 24, 2016

I installed the 1.4.50 build first, but it doesn't appear to have any options for specifying the SubDir for PlexRequests, or for any of the services interfacing with PlexRequests. Using this build, how am I supposed to set SubDirs for any of these things?

@tidusjar
Copy link
Member

@ruricu Correct, there are no options, it should just work with whatever path you run it under (or virtual directory).

If it's set up using nginx to run under http://localhost:4000/requests it should now redirect you to http://localhost:4000/requests/userlogin 🙏

@ruricu
Copy link

ruricu commented Mar 24, 2016

For one reason or another, I've been using WAMP/Apache handling my reverse proxies. To this end, a configuration like this has been sufficient:

<VirtualHost *:80>
    ServerName my.domain.here
    ProxyPass /sonarr http://localhost:8989/sonarr
    ProxyPassReverse /sonarr/ http://localhost:8989/sonarr
</VirtualHost>

After some trial and error, the only partially-functional configuration I could find for PR.Net is:

<VirtualHost *:80>
    ServerName my.domain.here
    ProxyPass /req/ http://localhost:3579/
    <Location /req/>
        ProxyPassReverse /
    </Location>
</VirtualHost>

I say "partial" in that mydomain.here/req/ correctly redirects to my.domain.here/req/userlogin and displays the basic login page, but all formatting/css/images are missing. Attempting to log in remains on my.domain.here/req/userlogin, but displays only the JSON response {"result":true, "message":null}. Every other link on the page does not respect the relative subdir paths.

It seems to me like this implementation is more obscure than what exists in the original PlexRequests, PlexPy, HtpcManager, Sonarr, SickRage, CouchPotato; where an explicit basepath is set in the app's configuration and, after restart, this is where the app is accessible, regardless of your proxy configuration. Is this intended to be more user-friendly than all of its predecessor and partner apps?

@tidusjar
Copy link
Member

Thank you for your feedback. I did not start this to make it 'more user-friendly', I started it because I wanted to try out a new .Net framework (Nancy). I admit that my experience with Nancy is lacking, but this is the primary reason for me doing this project (you know, all of this work is also done in my spare time). If you are finding it more 'obscure' there is nothing stopping you from using the original version of Plex Requests.

Thanks.

@Logvin
Copy link
Author

Logvin commented Mar 24, 2016

Just for the record.... it doesnt work in the original version of PlexRequests either, and the work you are doing here is flat out amazing. I really appreciate your work on this and will be looking for a way to donate as soon as my next paycheck comes :)

@tidusjar
Copy link
Member

Thank you @Logvin I have left an issue with the guys at Nancy, they have been amazing assisting me with some of the issues i've had. Hopefully they will be able to point me in the right direction to get this working for you.

@ruricu
Copy link

ruricu commented Mar 24, 2016

@tidusjar I'm sorry that my feedback came across as dismissive or condescending. That was truly nowhere near my intent. I am genuinely excited about the additional features you've implemented here as compared to the original PlexRequests.

What I was trying to convey is that you seem to be "divining" a url base from an external request in a way that is unique to your project when compared to the explicit configuration used in various "sister" applications. From a user-experience perspective, I think someone familiar with these sister applications might be confused to find this explicit configuration missing, and as a result, the asymmetry in the url base for internal and external addressing of this service. It is precisely because of this asymmetry that a simplistic apache mod_proxy does not function. In terms of "user friendliness" and "obscurity", I was merely referring to the configuration of url base functionality, not the PlexRequests.Net project as a whole.

Again; sorry to offend, and thanks for your hard work.

@jchannon
Copy link

So what I do is run the Nancy self host on 127.0.0.1 and then nginx to proxy calls. That way the Nancy app isnt exposed to the world.

var options = new StartOptions();
var urls = new[] { "http://127.0.0.1:1234", "http://localhost:1234" };
urls.ToList().ForEach(options.Urls.Add);

using (WebApp.Start<Startup>(options))
{
    Console.WriteLine("Running a http server on {0}", options.Urls.Aggregate((a, b) => a + ", " + b));
    do
    {
        Thread.Sleep(60000); //Required as Linux won't work for ReadKey
    } while (!Console.KeyAvailable);
}

Here's my nginx conf. Now bear in mind this has a load of SSL stuff which you probably don't need just to get a simple demo going but this all works in production.

daemon off;
worker_processes 1;

events {
    worker_connections 1024;
}

http {
    keepalive_timeout 65;

    server_tokens off;

    client_max_body_size 200m;
    client_body_timeout 300s;
    client_header_timeout 5s;

    large_client_header_buffers 2 4k;

    limit_req_zone $binary_remote_addr zone=vq:10m rate=400r/s;


    server {
        listen 80;
        return 301 https://$host$request_uri;
        add_header X-Frame-Options DENY;
        add_header X-Content-Type-Options nosniff;
        add_header X-XSS-Protection "1;mode=block";
    }

    server {
        listen 443;
        limit_req zone=vq burst=5;
        ssl_certificate     /certs/nginx.crt;
        ssl_certificate_key /certs/nginx.key;
        ssl on;
        ssl_session_cache builtin:1000 shared:SSL:10m;
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        ssl_ciphers ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+3DES:DH+3DES:RSA+AESGCM:RSA+AES:RSA+3DES:!aNULL:!MD5:!DSS;
        ssl_prefer_server_ciphers on;
        add_header Strict-Transport-Security "max-age=31536000; includeSubDomains;";
        add_header X-Frame-Options DENY;
        add_header X-Content-Type-Options nosniff;
        add_header X-XSS-Protection "1;mode=block";

        access_log /logs/nginx.log;
        error_log /logs/nginxerrors.log debug;

        location / {

            gzip  on;
            gzip_http_version 1.1;
            gzip_vary on;
            gzip_comp_level 6;
            gzip_proxied any;
            gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml
            application/xml+rss text/javascript application/javascript text/x-js;
            gzip_buffers 16 8k;
            gzip_disable "MSIE [1-6]\.(?!.*SV1)";

            proxy_buffering off;

            proxy_connect_timeout 90;
            proxy_send_timeout 90;
            proxy_read_timeout 90;

            proxy_set_header Host "localhost";
            proxy_set_header X-Host $host$request_uri;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;



            proxy_pass http://localhost:1924;
        }
    }
}

@tidusjar
Copy link
Member

Thanks for the help @jchannon does this work for anyone else?

@Logvin
Copy link
Author

Logvin commented Mar 25, 2016

@jchannon I gotta admit, what you are doing is a bit above my head.

Here is what I have in my NGINX.conf file:

  location /Requests {
        proxy_pass http://127.0.0.1:3579;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
    location /CouchPotato {
        proxy_pass https://127.0.0.1:5050;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }

Right now, when I go to domain.com/couchpotato, it loads couchpotato great. When I go to domain.com/requests, the URL is immediately changed to domain.com/userlogin and I get 404. This setup works great for Sonarr and CouchPotato.

@Logvin
Copy link
Author

Logvin commented Mar 25, 2016

@tidusjar I just installed the custom build you made, it did not help the redirect issue. When I go to domain.com/requests, the URL is immediately changed to domain.com/userlogin

@SaskiFX
Copy link

SaskiFX commented Apr 16, 2016

Found a missing BaseURL spot. Admin registration link for when you are creating a new account. I started with a fresh database.

@tidusjar
Copy link
Member

Damn! I thought I covered all areas.

@tidusjar tidusjar reopened this Apr 16, 2016
@SaskiFX
Copy link

SaskiFX commented Apr 16, 2016

Eh, its a lot of links to check. :) I was able to get registered and get in. Everything else seems to be working along with all my various sonarr, couchpotato, and pushover stuff.

@tidusjar
Copy link
Member

Excellent, glad to hear!

@mescon
Copy link

mescon commented Apr 16, 2016

eagerly waiting :-)

@tidusjar
Copy link
Member

@mescon 1.6.1 has been released :) Check the releases page. There is 1 place where the URL base doesn't work and that's when creating a admin

@mescon
Copy link

mescon commented Apr 16, 2016

... which I would probably like to do :) I'll wait for your next push.

@tidusjar
Copy link
Member

@mescon You can only create 1 administrator currently. So if you are using an existing database you will never go to that page.

@mescon
Copy link

mescon commented Apr 16, 2016

I don't have an existing database, I'm still on the lokenx version!

@SaskiFX
Copy link

SaskiFX commented Apr 16, 2016

When you click the link to make the admin account it will 404. Just add the base url in the address bar and it loads. Create the account and then you are good. Reload the site and your in. Everything else works as expected.

Sent from my iPhone

On Apr 16, 2016, at 1:19 PM, mescon notifications@github.com wrote:

I don't have an existing database, I'm still on the lokenx version!


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub

@mescon
Copy link

mescon commented Apr 16, 2016

Ah cool, will try - thx!

@Logvin
Copy link
Author

Logvin commented Apr 16, 2016

Thank you so much @tidusjar for bearing with us on this and getting it resolved. Shout out to @SaskiFX and @mescon for helping troubleshoot and provide input.

@Logvin Logvin closed this as completed Apr 16, 2016
@SaskiFX
Copy link

SaskiFX commented Apr 16, 2016

I think he still has one link to fix. :)

@tidusjar tidusjar reopened this Apr 16, 2016
@tidusjar
Copy link
Member

Correct. I'll leave this open. But I'm not going to push a release out just for that one link :)

@scipio314
Copy link

I'm having trouble getting this to work.

I install plexrequest and go to localhost:3579 and create an Admin account. I then create a URL base called 'request'. I hit save and then the css disappears. I then restart plexrequest.

I have tried localhost:3579 and it gives me 404 page not found. I then try domain/request and I also get 404 page not found. My apache settings are:

<Location /request>
ProxyPass http://localhost:3579
ProxyPassReverse http://localhost:3579

@tidusjar
Copy link
Member

Does http://localhost:3579/request work?

@scipio314
Copy link

yes thank you that worked. I changed my reverse proxy settings to:

<Location /request>
ProxyPass http://localhost:3579/request
ProxyPassReverse http://localhost:3579/request

@tidusjar
Copy link
Member

All fixed.

@khellang
Copy link

👏

@PhAzE-Variance
Copy link

PhAzE-Variance commented May 2, 2016

Im using the base url "requests" and it seems to work, except when i click on Admin i get the following error.

Error Details

Nancy.RequestExecutionException: Oh noes! ---> Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: `System.Dynamic.ExpandoObject' does not contain a definition for `SearchForMovies'
  at (wrapper dynamic-method) System.Object:CallSite.Target (System.Runtime.CompilerServices.Closure,System.Runtime.CompilerServices.CallSite,object)
  at RazorOutput.RazorView.Execute () <0x41f90fc0 + 0x00251> in :0 
  at Nancy.ViewEngines.Razor.NancyRazorViewBase`1[TModel].ExecuteView (System.String body, IDictionary`2 sectionContents) <0x41f742e0 + 0x00110> in :0 
  at (wrapper dynamic-method) System.Object:CallSite.Target (System.Runtime.CompilerServices.Closure,System.Runtime.CompilerServices.CallSite,object,object,object)
  at System.Dynamic.UpdateDelegates.UpdateAndExecuteVoid3[T0,T1,T2] (System.Runtime.CompilerServices.CallSite site, System.Dynamic.T0 arg0, System.Dynamic.T1 arg1, System.Dynamic.T2 arg2) <0x41f72e00 + 0x001ad> in :0 
  at (wrapper dynamic-method) System.Object:CallSite.Target (System.Runtime.CompilerServices.Closure,System.Runtime.CompilerServices.CallSite,object,object,object)
  at Nancy.ViewEngines.Razor.RazorViewEngine+<>c__DisplayClass2b.b__2a (System.IO.Stream stream) <0x41f33a50 + 0x002d3> in :0 
  at Nancy.Responses.MaterialisingResponse.PreExecute (Nancy.NancyContext context) <0x41f338d0 + 0x0006b> in :0 
  --- End of inner exception stack trace ---
  at Nancy.NancyEngine.InvokeOnErrorHook (Nancy.NancyContext context, Nancy.ErrorPipeline pipeline, System.Exception ex) <0x41f95870 + 0x0027f> in :0

At this point i am not able to access the admin page to remove the base url. Im using a docker but cant check the version of the app.

Edit: saw in the release notes that you can't use base url "requests". Wiped the db and used "request" instead, all good now.

@khellang
Copy link

khellang commented May 2, 2016

Maybe there should be a check for reserved URLs? 😛

@tidusjar
Copy link
Member

tidusjar commented May 2, 2016

That's true @khellang!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests