Opened 9 years ago

Closed 8 years ago

Last modified 6 years ago

#2677 closed bug (Fixed)

webui returns 404 error when used with --base

Reported by: fengshaun Owned by:
Priority: major Milestone: 2.0.0
Component: Web UI Version: 1.3.10
Keywords: base reverse_proxy Cc: fengshaun, miha.frangez@…

Description

I'm trying to use the webui under a subdirectory "/deluge/" instead of at the root "/". However, the --base option (or "base" in web.conf) seems to not be working properly and the webui's server doesn't seem to serve proper files under subdirectory. Please note that this is not a reverse proxy; this is just plain deluge-web running its own twisted server. In this case, I'm trying to access the webui at /deluge/ subdirectory.

deluge version:

$ deluge-web --version
deluge-web: 1.3.10
libtorrent: 0.16.17.0

web.conf

{
  "file": 1,
  "format": 1
}{
  "port": 8826,
  "enabled_plugins": [],
  "pwd_sha1": "xxxxxxxx",
  "theme": "gray",
  "show_sidebar": true,
  "sidebar_show_zero": false,
  "pkey": "ssl/daemon.pkey",
  "https": true,
  "sessions": {
    "xxxxxxxx": {
      "login": "xxxxxxxx",
      "expires": xxxxxxxx,
      "level": 10
    }
  },
  "base": "/deluge/",
  "pwd_salt": "xxxxxxxx",
  "show_session_speed": false,
  "first_login": false,
  "cert": "ssl/daemon.cert",
  "session_timeout": 3600,
  "default_daemon": "",
  "sidebar_multiple_filters": true
}

deluge-web output:

$ deluge-web --base "/deluge/" --loglevel=debug
[INFO    ] 20:47:04 ui:121 Deluge ui 1.3.10
[DEBUG   ] 20:47:04 ui:122 options: {'fork': False, 'profile': False, 'loglevel': 'debug', 'quiet': False, 'ssl': False, 'base': '/deluge/', 'logfile': None, 'config': None, 'port': None}
[DEBUG   ] 20:47:04 ui:123 args: []
[INFO    ] 20:47:04 ui:124 Starting web ui..
[DEBUG   ] 20:47:05 configmanager:111 Getting config 'web.conf'
[DEBUG   ] 20:47:05 config:197 Setting 'sidebar_show_zero' to False of <type 'bool'>
[DEBUG   ] 20:47:05 config:197 Setting 'show_session_speed' to False of <type 'bool'>
[DEBUG   ] 20:47:05 config:197 Setting 'first_login' to True of <type 'bool'>
[DEBUG   ] 20:47:05 config:197 Setting 'https' to False of <type 'bool'>
[DEBUG   ] 20:47:05 config:197 Setting 'sessions' to {} of <type 'dict'>
[DEBUG   ] 20:47:05 config:197 Setting 'enabled_plugins' to [] of <type 'list'>
[DEBUG   ] 20:47:05 config:197 Setting 'pwd_sha1' to xxxxxx of <type 'str'>
[DEBUG   ] 20:47:05 config:197 Setting 'cert' to ssl/daemon.cert of <type 'str'>
[DEBUG   ] 20:47:05 config:197 Setting 'pkey' to ssl/daemon.pkey of <type 'str'>
[DEBUG   ] 20:47:05 config:197 Setting 'port' to 8112 of <type 'int'>
[DEBUG   ] 20:47:05 config:197 Setting 'theme' to gray of <type 'str'>
[DEBUG   ] 20:47:05 config:197 Setting 'session_timeout' to 3600 of <type 'int'>
[DEBUG   ] 20:47:05 config:197 Setting 'show_sidebar' to True of <type 'bool'>
[DEBUG   ] 20:47:05 config:197 Setting 'default_daemon' to  of <type 'str'>
[DEBUG   ] 20:47:05 config:197 Setting 'sidebar_multiple_filters' to True of <type 'bool'>
[DEBUG   ] 20:47:05 config:197 Setting 'pwd_salt' to xxxxxxx of <type 'str'>
[DEBUG   ] 20:47:05 config:197 Setting 'base' to / of <type 'str'>
[DEBUG   ] 20:47:05 config:391 Config /srv/deluge/.config/deluge/web.conf version: 1.1 loaded: {'port': 8826, 'enabled_plugins': [], 'pwd_sha1': u'xxxxxx', 'theme': u'gray', 'show_sidebar': True, 'sidebar_show_zero': False, 'pkey': u'ssl/daemon.pkey', 'https': True, 'sessions': {u'xxxxxxx': {u'login': u'admin', u'expires': 1415482586.0, u'level': 10}}, 'base': u'/deluge/', 'pwd_salt': u'xxxxxxxxx', 'show_session_speed': False, 'first_login': False, 'cert': u'ssl/daemon.cert', 'session_timeout': 3600, 'default_daemon': u'', 'sidebar_multiple_filters': True}
[DEBUG   ] 20:47:05 server:253 Adding directory `/usr/lib/python2.7/site-packages/deluge/ui/web/css` with path ``
[DEBUG   ] 20:47:05 server:253 Adding directory `/usr/lib/python2.7/site-packages/deluge/ui/web/icons` with path ``
[DEBUG   ] 20:47:05 server:253 Adding directory `/usr/lib/python2.7/site-packages/deluge/ui/web/images` with path ``
[DEBUG   ] 20:47:05 json_api:315 Registering method: web.add_host
[DEBUG   ] 20:47:05 json_api:315 Registering method: web.add_torrents
[DEBUG   ] 20:47:05 json_api:315 Registering method: web.connect
[DEBUG   ] 20:47:05 json_api:315 Registering method: web.connected
[DEBUG   ] 20:47:05 json_api:315 Registering method: web.deregister_event_listener
[DEBUG   ] 20:47:05 json_api:315 Registering method: web.disconnect
[DEBUG   ] 20:47:05 json_api:315 Registering method: web.download_torrent_from_url
[DEBUG   ] 20:47:05 json_api:315 Registering method: web.get_config
[DEBUG   ] 20:47:05 json_api:315 Registering method: web.get_events
[DEBUG   ] 20:47:05 json_api:315 Registering method: web.get_host_status
[DEBUG   ] 20:47:05 json_api:315 Registering method: web.get_hosts
[DEBUG   ] 20:47:05 json_api:315 Registering method: web.get_magnet_info
[DEBUG   ] 20:47:05 json_api:315 Registering method: web.get_plugin_info
[DEBUG   ] 20:47:05 json_api:315 Registering method: web.get_plugin_resources
[DEBUG   ] 20:47:05 json_api:315 Registering method: web.get_plugins
[DEBUG   ] 20:47:05 json_api:315 Registering method: web.get_torrent_files
[DEBUG   ] 20:47:05 json_api:315 Registering method: web.get_torrent_info
[DEBUG   ] 20:47:05 json_api:315 Registering method: web.get_torrent_status
[DEBUG   ] 20:47:05 json_api:315 Registering method: web.register_event_listener
[DEBUG   ] 20:47:05 json_api:315 Registering method: web.remove_host
[DEBUG   ] 20:47:05 json_api:315 Registering method: web.set_config
[DEBUG   ] 20:47:05 json_api:315 Registering method: web.start_daemon
[DEBUG   ] 20:47:05 json_api:315 Registering method: web.stop_daemon
[DEBUG   ] 20:47:05 json_api:315 Registering method: web.update_ui
[DEBUG   ] 20:47:05 json_api:315 Registering method: web.upload_plugin
[DEBUG   ] 20:47:05 configmanager:111 Getting config 'hostlist.conf.1.2'
[DEBUG   ] 20:47:05 config:197 Setting 'hosts' to [('xxxxxxxxx', '127.0.0.1', 58846, '', '')] of <type 'list'>
[WARNING ] 20:47:05 config:361 Unable to open config file /srv/deluge/.config/deluge/hostlist.conf.1.2: [Errno 2] No such file or directory: '/srv/deluge/.config/deluge/hostlist.conf.1.2'
[DEBUG   ] 20:47:05 coreconfig:43 CoreConfig init..
[DEBUG   ] 20:47:05 sessionproxy:55 SessionProxy init..
[DEBUG   ] 20:47:05 json_api:315 Registering method: auth.change_password
[DEBUG   ] 20:47:05 json_api:315 Registering method: auth.check_session
[DEBUG   ] 20:47:05 json_api:315 Registering method: auth.delete_session
[DEBUG   ] 20:47:05 json_api:315 Registering method: auth.login
[DEBUG   ] 20:47:05 configmanager:111 Getting config 'web.conf'
[DEBUG   ] 20:47:05 pluginmanagerbase:65 Plugin manager init..
[DEBUG   ] 20:47:05 configmanager:111 Getting config 'web.conf'
[DEBUG   ] 20:47:05 pluginmanagerbase:124 Found plugin: AutoAdd 1.04 at /usr/lib/python2.7/site-packages/deluge/plugins/AutoAdd-1.04-py2.7.egg
[DEBUG   ] 20:47:05 pluginmanagerbase:124 Found plugin: Execute 1.3 at /usr/lib/python2.7/site-packages/deluge/plugins/Execute-1.3-py2.7.egg
[DEBUG   ] 20:47:05 pluginmanagerbase:124 Found plugin: Blocklist 1.3 at /usr/lib/python2.7/site-packages/deluge/plugins/Blocklist-1.3-py2.7.egg
[DEBUG   ] 20:47:05 pluginmanagerbase:124 Found plugin: Extractor 0.4 at /usr/lib/python2.7/site-packages/deluge/plugins/Extractor-0.4-py2.7.egg
[DEBUG   ] 20:47:05 pluginmanagerbase:124 Found plugin: Label 0.2 at /usr/lib/python2.7/site-packages/deluge/plugins/Label-0.2-py2.7.egg
[DEBUG   ] 20:47:05 pluginmanagerbase:124 Found plugin: Notifications 0.2 at /usr/lib/python2.7/site-packages/deluge/plugins/Notifications-0.2-py2.7.egg
[DEBUG   ] 20:47:05 pluginmanagerbase:124 Found plugin: WebUi 0.1 at /usr/lib/python2.7/site-packages/deluge/plugins/WebUi-0.1-py2.7.egg
[DEBUG   ] 20:47:05 pluginmanagerbase:124 Found plugin: Scheduler 0.2 at /usr/lib/python2.7/site-packages/deluge/plugins/Scheduler-0.2-py2.7.egg
[INFO    ] 20:47:05 server:661 Starting server in PID 17110.
[DEBUG   ] 20:47:05 server:589 Enabling SSL using:
[DEBUG   ] 20:47:05 server:590 Pkey: ssl/daemon.pkey
[DEBUG   ] 20:47:05 server:591 Cert: ssl/daemon.cert
[INFO    ] 20:47:05 server:681 serving on 0.0.0.0:8826 view at https://127.0.0.1:8826

--- this is where I navigated to https://127.0.0.1:8826/deluge/ and got "No such response"

[DEBUG   ] 20:47:06 server:589 Enabling SSL using:
[DEBUG   ] 20:47:06 server:590 Pkey: ssl/daemon.pkey
[DEBUG   ] 20:47:06 server:591 Cert: ssl/daemon.cert

--- this is where I shut down deluge-web

[INFO    ] 20:47:08 server:684 Shutting down webserver
[DEBUG   ] 20:47:08 server:688 Saving configuration file
[DEBUG   ] 20:47:08 server:704 Reactor not running

Output I get from webui when accessing /deluge/

<html>
  <head><title>404 - No Such Resource</title></head>
  <body>
    <h1>No Such Resource</h1>
    <p>No such child resource.</p>
  </body>
</html>

Accessing "/" returns this page, but it looks blank in the browser:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<title>Deluge: Web UI 1.3.10</title>
		
		<link rel="shortcut icon" href="/deluge/icons/deluge.png" type="image/png" />
		<link rel="icon" href="/deluge/icons/deluge.png" type="image/png" />
		<link rel="apple-touch-icon-precomposed" media="screen and (resolution: 163dpi)" href="/deluge/icons/apple-pre-57.png" />
		<link rel="apple-touch-icon-precomposed" media="screen and (resolution: 132dpi)" href="/deluge/icons/apple-pre-72.png" />
		<link rel="apple-touch-icon-precomposed" media="screen and (resolution: 326dpi)" href="/deluge/icons/apple-pre-114.png" />
		
		<!-- Stylesheets -->
		<link rel="stylesheet" type="text/css" href="/deluge/css/ext-all-notheme.css" />
		<link rel="stylesheet" type="text/css" href="/deluge/themes/css/xtheme-gray.css" />
		<link rel="stylesheet" type="text/css" href="/deluge/css/ext-extensions.css" />
		<link rel="stylesheet" type="text/css" href="/deluge/css/deluge.css" />

		<script type="text/javascript">
		deluge = {
			author: 'Damien Churchill <damoxc@gmail.com>',
			version: '1.3.10',
			config: {"sidebar_show_zero": false, "show_session_speed": false, "first_login": false, "theme": "gray", "base": "/deluge/", "sidebar_multiple_filters": true}
		}
		</script>

		<!-- Javascript -->
		<script type="text/javascript" src="/deluge/gettext.js"></script>
		<script type="text/javascript" src="/deluge/js/ext-base.js"></script>
		<script type="text/javascript" src="/deluge/js/ext-all.js"></script>
		<script type="text/javascript" src="/deluge/js/ext-extensions.js"></script>
		<script type="text/javascript" src="/deluge/js/deluge-all.js"></script>
		<script type="text/javascript">
			Deluge.debug = false;
		</script>
	</head>
	<body>
		<div style="background-image: url('/deluge/themes/images/default/tree/loading.gif');"></div>

		<!-- Preload icon classes -->
		<div class="ext-mb-error"></div>
		<div class="icon-ok"></div>
	</body>
</html>

I think the problem may be that the twisted server ignores the --base option and so cannot serve static files under /deluge/ which it thinks does not exist.

Attachments (1)

deluge_webui_base.patch (522 bytes) - added by fengshaun 9 years ago.
temporary fix for --base being ignored by twisted web server

Download all attachments as: .zip

Change History (12)

comment:1 Changed 9 years ago by fengshaun

  • Cc fengshaun added

Changed 9 years ago by fengshaun

temporary fix for --base being ignored by twisted web server

comment:2 Changed 9 years ago by fengshaun

I have attached a *proof of concept* patch. I hope it'll help find a proper solution.

comment:3 Changed 8 years ago by franga2000

I just upgraded to 1.3.12 which is the default for Ubuntu 16.04 (LTS!) and I've run into this bug. The generator seems to be using the prefix, but the web server isn't. Everything worked fine on 1.3.6.

Any progress on fixing it?

comment:4 Changed 8 years ago by franga2000

  • Cc miha.frangez@… added

comment:5 Changed 8 years ago by Cas

  • Milestone set to 1.3.x

comment:6 follow-up: Changed 8 years ago by bro

As far as I understand, the --base option never caused the WebUI to be served on a subdir on the twisted server, so how this could have worked fine on 1.3.6 is beyond my understanding.

This option is meant for to be used with a reverse proxy as explained here: http://dev.deluge-torrent.org/wiki/UserGuide/WebUI/ReverseProxy

The patch works, but then requires the proxy config to point to twisted-server:8112/base-arg/

comment:7 in reply to: ↑ 6 Changed 8 years ago by franga2000

Replying to bro:

As far as I understand, the --base option never caused the WebUI to be served on a subdir on the twisted server, so how this could have worked fine on 1.3.6 is beyond my understanding.

This option is meant for to be used with a reverse proxy as explained here: http://dev.deluge-torrent.org/wiki/UserGuide/WebUI/ReverseProxy

The patch works, but then requires the proxy config to point to twisted-server:8112/base-arg/

I see. I thought it was a bug when in fact it was a bugfix. IMO the old way would still make more sense. Prefixing only static files is confusing, even tho there's only one actual page.

comment:8 Changed 8 years ago by bro

I'm not following. Nothing has been changed in this regards, and it should work exactly as it did in the latest version (1.3.12) as when it was implemented in v1.3.0.

As far as I understand there is no bug and there is no bug fix. The patch changes the behavior of the --base option to serve the WebUI on a subdir which allows viewing the WebUI served directly from the twisted web server (http://IP:8111/base).

What I wonder is why you even need to specify the base manually with the base option when you can use the RequestHeader option as shown here: http://dev.deluge-torrent.org/wiki/UserGuide/WebUI/ReverseProxy

comment:9 Changed 8 years ago by franga2000

When I set up my server on 1.3.6, I didn't know about the header, so I used --base.
After I upgraded to 1.3.12, the exact same config stopped working (everything was 404).

I found this bug report and thought the OP was saying that the base was supposed to aply to twisted too. I figured that's the change that caused the 404s, when in fact, there was no change and something else was broken.

I rewrote my configs to use the headers and now everything works as expected.

comment:10 Changed 8 years ago by Cas

  • Milestone changed from 1.3.x to 2.0
  • Resolution set to Fixed
  • Status changed from new to closed

This is now a feature in develop: [64ac5fdf73f2fecc]

(It won't be in 1.3)

comment:11 Changed 6 years ago by Cas

  • Milestone changed from 2.0 to 2.0.0

Milestone renamed

Note: See TracTickets for help on using tickets.