lgallard / qBittorrent-Controller

qBittorrent Controller - An Android app for controlling qBittorrent servers
MIT License
286 stars 58 forks source link

qBittorrent-Controller does not work with nginx proxy, get bad request(400) #153

Closed azuwis closed 6 years ago

azuwis commented 6 years ago

I've setup nginx to proxy https request to qbittorrent as suggested here and here.

While qbittorrent webui works fine using web browser(firefox or google chrome), qbittorrent-controller does not work with nginx proxy, but direct connect to qbittorrent works.

It turns out this commit introduced the problem.

According to RFC 2616, Host: should only contain host and port, but not protocol and others.

Try making request with similar Host: to google.com, will get bad request too:

$ curl --header 'Host: https://www.google.com/' https://www.google.com/
<html><title>Error 400 (Bad Request)!!1</title></html>

Although direct connect to qbittorrent works, using nginx proxy give a much secure setup, please fix it.

lgallard commented 6 years ago

@azuwis

Release #154 (version 4.5.6) should fix the issue.

azuwis commented 6 years ago

Updated qBittorrent-Controller from Play Store to 4.5.7, and still see 400:

GET /json/events HTTP/1.1
Cookie: 
Referer: http://<server>:<port>
Host: http://<server>:<port>
Connection: Keep-Alive
User-Agent: qBittorrent for Android

HTTP/1.1 400 Bad Request
Server: nginx/1.13.6
Date: Mon, 27 Nov 2017 02:46:22 GMT
Content-Type: text/html
Content-Length: 173
Connection: close

<html>
<head><title>400 Bad Request</title></head>
<body bgcolor="white">
<center><h1>400 Bad Request</h1></center>
<hr><center>nginx/1.13.6</center>
</body>
</html>

A quick look at the code, and find httpget.setHeader("Host", this.protocol... still exists in multiple places, e.g. here.

lgallard commented 6 years ago

@azuwis thanks for pointed it out. I there's a new release #157 (version 4.5.8). Regards!

azuwis commented 6 years ago

4.5.8 works, Thanks :)

Closing the issue.

lgallard commented 6 years ago

You are welcome!