FWIW: I ran into this problem again, so I did some more research:
With a wrong sub-URL, things go wrong: redirection to localhost. Example:
Code: Select all
sander@flappie:~$ curl http://192.168.1.101:8080/doesnotexist
<html>
<head>
<script type="text/javascript">
<!--
location.href = "http://localhost:8080/sabnzbd"
//-->
</script>
</head>
<body><br/></body>
</html>
sander@flappie:~$
The redirect (?) to localhost is not good. I searched the code, and it's in sabnzbd/panic.py
Code: Select all
def error_page_404(status, message, traceback, version):
""" Custom handler for 404 error, redirect to main page """
import cherrypy
return r'''
<html>
<head>
<script type="text/javascript">
<!--
location.href = "%s"
//-->
</script>
</head>
<body><br/></body>
</html>
''' % cherrypy.wsgiserver.REDIRECT_URL
So far I found this in the code:
Code: Select all
$ grep -ir error_page.404 *
sabnzbd/panic.py:def error_page_404(status, message, traceback, version):
SABnzbd.py: 'error_page.404': sabnzbd.panic.error_page_404
Code: Select all
$ grep -ir REDIRECT_URL *
cherrypy/wsgiserver/__init__.py:REDIRECT_URL = None # Application can write it's HTTP-->HTTPS redirection URL here
cherrypy/wsgiserver/__init__.py: if REDIRECT_URL:
cherrypy/wsgiserver/__init__.py: req.simple_response("301 Moved Permanently", REDIRECT_URL)
sabnzbd/panic.py:''' % cherrypy.wsgiserver.REDIRECT_URL
SABnzbd.py: cherrypy.wsgiserver.REDIRECT_URL = browser_url
The corresponding code in SABnzbd.py is:
Code: Select all
if enable_https:
browser_url = "https://%s:%s/sabnzbd" % (browserhost, cherryport)
else:
browser_url = "http://%s:%s/sabnzbd" % (browserhost, cherryport)
cherrypy.wsgiserver.REDIRECT_URL = browser_url
cherrypy.wsgiserver.REDIRECT_URL is:
http://localhost:8080/sabnzbd
... and that's wrong; it should redirect to the FQDN that is used in the request itself, which can only be found at the moment the request is sent by the client. Not in the early startup phase of SABnzbd.
TBC