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

Proxy Config #72

Open
SteffanCline opened this issue Feb 18, 2022 · 13 comments
Open

Proxy Config #72

SteffanCline opened this issue Feb 18, 2022 · 13 comments

Comments

@SteffanCline
Copy link

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

@pannal
Copy link
Owner

pannal commented Feb 18, 2022

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?

@SteffanCline
Copy link
Author

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

@SteffanCline
Copy link
Author

@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"

@SteffanCline
Copy link
Author

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.

@SteffanCline
Copy link
Author

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
Copy link
Owner

pannal commented Feb 19, 2022

@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).

@pannal
Copy link
Owner

pannal commented Feb 19, 2022

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

@SteffanCline
Copy link
Author

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/)

@SteffanCline
Copy link
Author

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

@pannal
Copy link
Owner

pannal commented Feb 19, 2022

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

@pannal
Copy link
Owner

pannal commented Feb 19, 2022

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.

@SteffanCline
Copy link
Author

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

@pannal
Copy link
Owner

pannal commented Feb 19, 2022

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.

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

No branches or pull requests

2 participants