Skip to content

Scrapy, a fast high-level web crawling & scraping framework for Python.

scrapyd: support bind to a specific ip address

lostsnow5afe4f50c123
diff --git a/docs/topics/scrapyd.rst b/docs/topics/scrapyd.rst
index 3a14955f3..0fe2aa3a6 100644
--- a/docs/topics/scrapyd.rst
+++ b/docs/topics/scrapyd.rst
@@ -153,6 +153,11 @@ http_port
The TCP port where the HTTP JSON API will listen. Defaults to ``6800``.
+bind_address
+------------
+
+The IP address where the HTTP JSON API will listen. Defaults to ``0.0.0.0`` (all)
+
max_proc
--------
diff --git a/scrapyd/app.py b/scrapyd/app.py
index 7ae69ddf3..6c860e740 100644
--- a/scrapyd/app.py
+++ b/scrapyd/app.py
@@ -15,6 +15,7 @@ from .config import Config
def application(config):
app = Application("Scrapyd")
http_port = config.getint('http_port', 6800)
+ bind_address = config.get('bind_address', '0.0.0.0')
poller = QueuePoller(config)
eggstorage = FilesystemEggStorage(config)
@@ -28,8 +29,8 @@ def application(config):
launcher = Launcher(config, app)
timer = TimerService(5, poller.poll)
- webservice = TCPServer(http_port, server.Site(Root(config, app)))
- log.msg("Scrapyd web console available at http://localhost:%s/" % http_port)
+ webservice = TCPServer(http_port, server.Site(Root(config, app)), interface=bind_address)
+ log.msg("Scrapyd web console available at http://%s:%s/" % (bind_address, http_port))
launcher.setServiceParent(app)
timer.setServiceParent(app)