GerryDazoo / Slinger

Reuse SlingBox hardware without SlingBox Servers
170 stars 34 forks source link

Internal Server Error when using nginx proxy manager #646

Closed jfgarciamex closed 4 months ago

jfgarciamex commented 4 months ago

Hi, I'm trying to use ngxinx proxy manager with slinger, but when I try to use I keep getting and Internal Server Error. For example, if I configure sling.test.net to forward it to the slinger server, I get the following in the slinger log:

02/20/2024, 20:26:52.249   RemoteControl connection from ('172.23.0.2', 44552)
Remote Control Connected
GET remote/
[2024-02-20 20:26:52,251] ERROR in app: Exception on /remote/ [GET]
Traceback (most recent call last):
  File "/home/slingbox/.env/lib/python3.11/site-packages/flask/app.py", line 1463, in wsgi_app
    response = self.full_dispatch_request()
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/slingbox/.env/lib/python3.11/site-packages/flask/app.py", line 872, in full_dispatch_request
    rv = self.handle_user_exception(e)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/slingbox/.env/lib/python3.11/site-packages/flask/app.py", line 870, in full_dispatch_request
    rv = self.dispatch_request()
         ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/slingbox/.env/lib/python3.11/site-packages/flask/app.py", line 855, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/slingbox/slingbox_server.py", line 1578, in index
    streamer, client, remote = get_streamer( request, text )
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/slingbox/slingbox_server.py", line 1520, in get_streamer
    port = request.headers.get('Host').split(':')[1]
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^
IndexError: list index out of range

I think the request from nginx proxy manager is not being managed correctly by slinger, as 172.23.0.2 is not the ip address of my client. Any suggestion to fix this. Thanks!

GerryDazoo commented 4 months ago

NGINX is not populating the "Host" information in the response. This is an NGINX problem not my code.

jfgarciamex commented 4 months ago

@GerryDazoo one more question, could be that instead of the host what is missing is the port? I'm asking as I found some issues reported already on the nginx proxy manager config, that may be missing the port in the forward url. Thanks!

jfgarciamex commented 4 months ago

@GerryDazoo,well, after investigating a bit, I found that adding the following directive to the custom location section solves the issue (so the problem is that the response does not include the port):

proxy_set_header Host $http_host:$proxy_port;

Thanks for your help!