pannal / Kitana

A responsive Plex plugin web frontend

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Proxy Config

SteffanCline opened this issue · comments

Trying to get kitana to run through an apache proxy so I can access it via https://mydomain.tld/kitana. I'm sure I have the apache config right but what are the correct flags for the service file?

Currently I'm trying this with no success:
ExecStart=/usr/bin/python3 /opt/Kitana/kitana.py --behind-proxy=true --prefix=/kitana

You might need to look at -PB and -PH. I've never used Kitana with Apache, but with NGINX it works fine.

What are the errors you see?

This is my apache config

##kitana##
<Location /kitana>
    ProxyPass http://localhost:31337/kitana
    ProxyPassReverse http://localhost:31337/kitana
    Order deny,allow
    Deny from all
    Allow from all
</Location>

Screen Shot 2022-02-18 at 10 37 38 AM

@pannal, while waiting for your help, I've been tinkering a bit. This will work with regular http but not https.

ExecStart=/usr/bin/python3 /opt/Kitana/kitana.py -p /kitana -P -PH "X-Forwarded-Host"

Ok, more progress. It seems that Kitana is specifying http:// in several places where it's not needed. If that was left out, it would work fine. The browser sees the page loaded as https then the html is asking for http so by default, it won't mix http and https on the same page. That's the remaining issue.

in base.jinja2 line 16
change <link rel="stylesheet" href="{{ static("/static/css/main.css") }}"/> to <link rel="stylesheet" href="{{ url("/static/css/main.css") }}"/>

In the index.jinja2 you have <img src="{{ url(d.thumb) }}" class="rounded-left"/> and it's creating the URL
http://domain.tld/kitana/pms_asset?url=%253A%252Fplugins%252Fcom.plexapp.agents.subzero%252Fresources%252Ficon-sub.jpg%253Ft%253D1643092363

Again, because it's not properly putting in https it causes issues. It really doesn't need anything before /kitana. I can't find where in the code you do that so I can try altering the code to fix the issue. I'm a novice with python.

@pannal, while waiting for your help, I've been tinkering a bit. This will work with regular http but not https.

ExecStart=/usr/bin/python3 /opt/Kitana/kitana.py -p /kitana -P -PH "X-Forwarded-Host"

I told you exactly what you might need to look at in my first reply. -PB and -PH. You've found the latter on "your own" :D

Try setting proxy base (the first parameter I hinted at) to https://yourdomain (without slash at the end, without /kitana - see README).

Also, you might need to add a rewrite for the statics, as per sample conf: https://github.com/pannal/Kitana/blob/master/deployment/nginx/sample.conf

Putting in the host made it work. I wonder what's so different with your engine than all the other typical *arr apps where the simple apache location and adding /kitana is enough. Not my place to challenge. :-)

Hitting restart plugin on SubZero results in this:

500 Internal Server Error
The server encountered an unexpected condition which prevented it from fulfilling the request.

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 445, in _make_request
    six.raise_from(e, None)
  File "<string>", line 3, in raise_from
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 440, in _make_request
    httplib_response = conn.getresponse()
  File "/usr/lib/python3.9/http/client.py", line 1371, in getresponse
    response.begin()
  File "/usr/lib/python3.9/http/client.py", line 319, in begin
    version, status, reason = self._read_status()
  File "/usr/lib/python3.9/http/client.py", line 280, in _read_status
    line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
  File "/usr/lib/python3.9/socket.py", line 704, in readinto
    return self._sock.recv_into(b)
  File "/usr/lib/python3.9/ssl.py", line 1241, in recv_into
    return self.read(nbytes, buffer)
  File "/usr/lib/python3.9/ssl.py", line 1099, in read
    return self._sslobj.read(len, buffer)
socket.timeout: The read operation timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/dist-packages/requests/adapters.py", line 439, in send
    resp = conn.urlopen(
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 755, in urlopen
    retries = retries.increment(
  File "/usr/lib/python3/dist-packages/urllib3/util/retry.py", line 532, in increment
    raise six.reraise(type(error), error, _stacktrace)
  File "/usr/lib/python3/dist-packages/six.py", line 719, in reraise
    raise value
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 699, in urlopen
    httplib_response = self._make_request(
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 447, in _make_request
    self._raise_timeout(err=e, url=url, timeout_value=read_timeout)
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 336, in _raise_timeout
    raise ReadTimeoutError(
urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='192-168-0-6.c72eb271f34b4b94aea254623e07123f.plex.direct', port=32400): Read timed out. (read timeout=5)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/dist-packages/cherrypy/_cprequest.py", line 638, in respond
    self._do_respond(path_info)
  File "/usr/local/lib/python3.9/dist-packages/cherrypy/_cprequest.py", line 697, in _do_respond
    response.body = self.handler()
  File "/usr/local/lib/python3.9/dist-packages/cherrypy/lib/encoding.py", line 223, in __call__
    self.body = self.oldhandler(*args, **kwargs)
  File "/usr/local/lib/python3.9/dist-packages/cherrypy/_cpdispatch.py", line 54, in __call__
    return self.callable(*self.args, **self.kwargs)
  File "/opt/Kitana/kitana.py", line 633, in plugin_restart
    r = self._dispatch(path)
  File "/opt/Kitana/kitana.py", line 158, in _dispatch
    r = self.session.get(self.server_addr + path, headers=headers, params=data, **self.req_defaults)
  File "/usr/local/lib/python3.9/dist-packages/requests/sessions.py", line 555, in get
    return self.request('GET', url, **kwargs)
  File "/usr/local/lib/python3.9/dist-packages/requests/sessions.py", line 542, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/lib/python3.9/dist-packages/requests/sessions.py", line 655, in send
    r = adapter.send(request, **kwargs)
  File "/usr/local/lib/python3.9/dist-packages/requests/adapters.py", line 529, in send
    raise ReadTimeout(e, request=request)
requests.exceptions.ReadTimeout: HTTPSConnectionPool(host='192-168-0-6.c72eb271f34b4b94aea254623e07123f.plex.direct', port=32400): Read timed out. (read timeout=5)
Powered by [CherryPy 18.6.1](http://www.cherrypy.org/)

Perhaps it's related to this? I'm fairly certain I did activate it per the instructions. The checkbox is toggled and the settings are configured. I see the subzero process running.
Screen Shot 2022-02-19 at 12 35 44 PM

That's this issue: pannal/Sub-Zero.bundle#753

Putting in the host made it work. I wonder what's so different with your engine than all the other typical *arr apps where the simple apache location and adding /kitana is enough. Not my place to challenge. :-)

Hitting restart plugin on SubZero results in this:

500 Internal Server Error
The server encountered an unexpected condition which prevented it from fulfilling the request.

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 445, in _make_request
    six.raise_from(e, None)
  File "<string>", line 3, in raise_from
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 440, in _make_request
    httplib_response = conn.getresponse()
  File "/usr/lib/python3.9/http/client.py", line 1371, in getresponse
    response.begin()
  File "/usr/lib/python3.9/http/client.py", line 319, in begin
    version, status, reason = self._read_status()
  File "/usr/lib/python3.9/http/client.py", line 280, in _read_status
    line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
  File "/usr/lib/python3.9/socket.py", line 704, in readinto
    return self._sock.recv_into(b)
  File "/usr/lib/python3.9/ssl.py", line 1241, in recv_into
    return self.read(nbytes, buffer)
  File "/usr/lib/python3.9/ssl.py", line 1099, in read
    return self._sslobj.read(len, buffer)
socket.timeout: The read operation timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/dist-packages/requests/adapters.py", line 439, in send
    resp = conn.urlopen(
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 755, in urlopen
    retries = retries.increment(
  File "/usr/lib/python3/dist-packages/urllib3/util/retry.py", line 532, in increment
    raise six.reraise(type(error), error, _stacktrace)
  File "/usr/lib/python3/dist-packages/six.py", line 719, in reraise
    raise value
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 699, in urlopen
    httplib_response = self._make_request(
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 447, in _make_request
    self._raise_timeout(err=e, url=url, timeout_value=read_timeout)
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 336, in _raise_timeout
    raise ReadTimeoutError(
urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='192-168-0-6.c72eb271f34b4b94aea254623e07123f.plex.direct', port=32400): Read timed out. (read timeout=5)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/dist-packages/cherrypy/_cprequest.py", line 638, in respond
    self._do_respond(path_info)
  File "/usr/local/lib/python3.9/dist-packages/cherrypy/_cprequest.py", line 697, in _do_respond
    response.body = self.handler()
  File "/usr/local/lib/python3.9/dist-packages/cherrypy/lib/encoding.py", line 223, in __call__
    self.body = self.oldhandler(*args, **kwargs)
  File "/usr/local/lib/python3.9/dist-packages/cherrypy/_cpdispatch.py", line 54, in __call__
    return self.callable(*self.args, **self.kwargs)
  File "/opt/Kitana/kitana.py", line 633, in plugin_restart
    r = self._dispatch(path)
  File "/opt/Kitana/kitana.py", line 158, in _dispatch
    r = self.session.get(self.server_addr + path, headers=headers, params=data, **self.req_defaults)
  File "/usr/local/lib/python3.9/dist-packages/requests/sessions.py", line 555, in get
    return self.request('GET', url, **kwargs)
  File "/usr/local/lib/python3.9/dist-packages/requests/sessions.py", line 542, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/lib/python3.9/dist-packages/requests/sessions.py", line 655, in send
    r = adapter.send(request, **kwargs)
  File "/usr/local/lib/python3.9/dist-packages/requests/adapters.py", line 529, in send
    raise ReadTimeout(e, request=request)
requests.exceptions.ReadTimeout: HTTPSConnectionPool(host='192-168-0-6.c72eb271f34b4b94aea254623e07123f.plex.direct', port=32400): Read timed out. (read timeout=5)
Powered by [CherryPy 18.6.1](http://www.cherrypy.org/)

That's an issue I can't solve - routing. Wherever/whatever runs Kitana can't reach that host.

It's all on the same host. Any ideas how to resolve that?

It's all on the same host. Any ideas how to resolve that?

No idea. You can select a different "connection type" to connect to your Plex, though. Through the server selection screen in Kitana (click your server name). Use something local.