Change back-end port from 5000

What is the problem?
I am running Octopi behind my Synology NAS' reverse proxy. The webcam stream works perfectly from outside my network. But the Web UI part gets redirected to the Synology's UI because the NAS also uses port 5000.

Is there a way to change this back-end port?

What did you already try to solve it?
Changed the back-end port to 5010 but this breaks the Octopi's UI.

Additional information about your setup (OctoPrint version, OctoPi version, printer, firmware, octoprint.log, serial.log or output on terminal tab, ...)


OctoPrint version : 1.3.10
OctoPi version : 0.16.0

Line that I changed:
server octoprint1 127.0.0.1:5000
within:

sudo nano /etc/haproxy/haproxy.cfg:

global
        maxconn 4096
        user haproxy
        group haproxy
        log 127.0.0.1 local1 debug

defaults
        log     global
        mode    http
        option  httplog
        option  dontlognull
        retries 3
        option redispatch
        option http-server-close
        option forwardfor
        maxconn 2000
        timeout connect 5s
        timeout client  15min
        timeout server  15min

frontend public
        bind :::2200 v4v6
        bind :::443 v4v6 ssl crt /etc/ssl/snakeoil.pem
        option forwardfor except 127.0.0.1
        use_backend webcam if { path_beg /webcam/ }
        default_backend octoprint

backend octoprint
        acl needs_scheme req.hdr_cnt(X-Scheme) eq 0

        reqrep ^([^\ :]*)\ /(.*) \1\ /\2
        reqadd X-Scheme:\ https if needs_scheme { ssl_fc }
        reqadd X-Scheme:\ http if needs_scheme !{ ssl_fc }
        option forwardfor
        server octoprint1 127.0.0.1:5010
        errorfile 503 /etc/haproxy/errors/503-no-octoprint.http

backend webcam
        reqrep ^([^\ :]*)\ /webcam/(.*)     \1\ /\2
        server webcam1  127.0.0.1:8080
        errorfile 503 /etc/haproxy/errors/503-no-webcam.http

Error when changing the back-end port:

Octoprint log:

pi@octopi:~ $ cat ~/.octoprint/logs/octoprint.log

2019-03-15 01:28:59,581 - octoprint.startup - INFO - ******************************************************************************
2019-03-15 01:28:59,584 - octoprint.startup - INFO - Starting OctoPrint 1.3.10
2019-03-15 01:28:59,584 - octoprint.startup - INFO - ******************************************************************************
2019-03-15 01:29:00,907 - octoprint.startup - INFO - We don't appear to be online, not fetching plugin blacklist
2019-03-15 01:29:00,979 - octoprint.plugin.core - INFO - Loading plugins from /home/pi/oprint/lib/python2.7/site-packages/octoprint/plugins, /home/pi/.octoprint/plugins and installed plugin packages...
2019-03-15 01:29:03,908 - octoprint.plugin.core - INFO - Found 15 plugin(s) providing 15 mixin implementations, 17 hook handlers
2019-03-15 01:29:04,046 - octoprint.server.heartbeat - INFO - Starting server heartbeat, 900.0s interval
2019-03-15 01:29:04,103 - octoprint.server - INFO - Intermediary server started
2019-03-15 01:29:04,104 - octoprint.plugin.core - INFO - Loading plugins from /home/pi/oprint/lib/python2.7/site-packages/octoprint/plugins, /home/pi/.octoprint/plugins and installed plugin packages...
2019-03-15 01:29:04,824 - octoprint.plugin.core - INFO - Found 15 plugin(s) providing 15 mixin implementations, 17 hook handlers
2019-03-15 01:29:04,869 - octoprint.filemanager.storage - INFO - Initializing the file metadata for /home/pi/.octoprint/uploads...
2019-03-15 01:29:04,871 - octoprint.filemanager.storage - INFO - ... file metadata for /home/pi/.octoprint/uploads initialized successfully.
2019-03-15 01:29:04,894 - octoprint.plugins.tracking - INFO - Initialized anonymous tracking
2019-03-15 01:29:04,939 - octoprint.plugins.softwareupdate - INFO - Loaded version cache from disk
2019-03-15 01:29:07,027 - octoprint.util.pip - INFO - Using "/home/pi/oprint/bin/python2 -m pip" as command to invoke pip
2019-03-15 01:29:08,640 - octoprint.util.pip - INFO - Version of pip is 19.0.1
2019-03-15 01:29:08,642 - octoprint.util.pip - INFO - pip installs to /home/pi/oprint/lib/python2.7/site-packages (writable -> yes), --user flag needed -> no, virtual env -> yes
2019-03-15 01:29:08,642 - octoprint.util.pip - INFO - ==> pip ok -> yes
2019-03-15 01:29:08,648 - octoprint.plugin.core - INFO - Initialized 15 plugin implementation(s)
2019-03-15 01:29:08,659 - octoprint.plugin.core - INFO - 15 plugin(s) registered with the system:
|  Action Command Prompt Support (bundled) = /home/pi/oprint/lib/python2.7/site-packages/octoprint/plugins/action_command_prompt
|  Announcement Plugin (bundled) = /home/pi/oprint/lib/python2.7/site-packages/octoprint/plugins/announcements
|  Anonymous Usage Tracking (bundled) = /home/pi/oprint/lib/python2.7/site-packages/octoprint/plugins/tracking
|  Application Keys Plugin (bundled) = /home/pi/oprint/lib/python2.7/site-packages/octoprint/plugins/appkeys
|  Backup & Restore (bundled) = /home/pi/oprint/lib/python2.7/site-packages/octoprint/plugins/backup
|  Core Wizard (bundled) = /home/pi/oprint/lib/python2.7/site-packages/octoprint/plugins/corewizard
|  CuraEngine (<= 15.04) (bundled) = /home/pi/oprint/lib/python2.7/site-packages/octoprint/plugins/cura
|  Discovery (bundled) = /home/pi/oprint/lib/python2.7/site-packages/octoprint/plugins/discovery
|  Force Login (bundled) = /home/pi/oprint/lib/python2.7/site-packages/octoprint/plugins/forcelogin
|  Logging (bundled) = /home/pi/oprint/lib/python2.7/site-packages/octoprint/plugins/logging
|  Pi Support Plugin (bundled) = /home/pi/oprint/lib/python2.7/site-packages/octoprint/plugins/pi_support
|  Plugin Manager (bundled) = /home/pi/oprint/lib/python2.7/site-packages/octoprint/plugins/pluginmanager
|  Printer Safety Check (bundled) = /home/pi/oprint/lib/python2.7/site-packages/octoprint/plugins/printer_safety_check
|  Software Update (bundled) = /home/pi/oprint/lib/python2.7/site-packages/octoprint/plugins/softwareupdate
|  Virtual Printer (bundled) = /home/pi/oprint/lib/python2.7/site-packages/octoprint/plugins/virtual_printer
2019-03-15 01:29:08,684 - octoprint.environment - INFO - Detected environment is Python 2.7.13 under Linux (linux2). Details:
|  hardware:
|    cores: 4
|    freq: 1200.0
|    ram: 918188032
|  os:
|    id: linux
|    platform: linux2
|  plugins:
|    pi_support:
|      model: Raspberry Pi 3 Model B Rev 1.2
|      octopi_version: 0.16.0
|  python:
|    pip: 19.0.1
|    version: 2.7.13
|    virtualenv: /home/pi/oprint
2019-03-15 01:29:08,700 - octoprint.server - INFO - Reset webasset folder /home/pi/.octoprint/generated/webassets...
2019-03-15 01:29:08,719 - octoprint.server - INFO - Reset webasset folder /home/pi/.octoprint/generated/.webassets-cache...
2019-03-15 01:29:09,150 - octoprint.server - INFO - Shutting down intermediary server...
2019-03-15 01:29:09,190 - octoprint.server - INFO - Intermediary server shut down
2019-03-15 01:29:09,192 - octoprint.events - INFO - Processing startup event, this is our first event
2019-03-15 01:29:09,193 - octoprint.events - INFO - Adding 0 events to queue that were held back before startup event
2019-03-15 01:29:09,195 - octoprint.filemanager - INFO - Adding backlog items from all storage types to analysis queue...
2019-03-15 01:29:09,200 - octoprint.filemanager - INFO - Added 0 items from storage type "local" to analysis queue
2019-03-15 01:29:09,219 - octoprint.plugins.discovery - INFO - Registered 'OctoPrint instance on octopi' for _http._tcp
2019-03-15 01:29:09,233 - octoprint.plugins.discovery - INFO - Registered 'OctoPrint instance on octopi' for _octoprint._tcp
2019-03-15 01:29:09,244 - octoprint.plugins.discovery - INFO - Registered OctoPrint instance on octopi for SSDP
2019-03-15 01:29:09,259 - octoprint.server - INFO - Listening on http://127.0.0.1:5000
2019-03-15 01:29:09,297 - octoprint.plugins.pluginmanager - INFO - Loaded plugin repository data from disk, was still valid
2019-03-15 01:29:09,758 - octoprint.plugins.pluginmanager - INFO - Loaded notice data from disk, was still valid
2019-03-15 01:29:10,937 - octoprint.util.pip - INFO - Using "/home/pi/oprint/bin/python2 -m pip" as command to invoke pip
2019-03-15 01:29:10,939 - octoprint.util.pip - INFO - pip installs to /home/pi/oprint/lib/python2.7/site-packages (writable -> yes), --user flag needed -> no, virtual env -> yes
2019-03-15 01:29:10,939 - octoprint.util.pip - INFO - ==> pip ok -> yes
2019-03-15 01:29:10,997 - octoprint.util.connectivity_checker - INFO - Connectivity changed from offline to online
2019-03-15 01:29:11,023 - octoprint.plugins.pluginmanager - INFO - Loaded plugin repository data from disk, was still valid
2019-03-15 01:29:11,556 - octoprint.plugins.pluginmanager - INFO - Loaded notice data from disk, was still valid
2019-03-15 01:29:11,649 - octoprint.server.preemptive_cache - INFO - Preemptively caching / (ui _default) for {'query_string': 'l10n=en', 'path': '/', 'base_url': 'http://octopi.lan/'}
2019-03-15 01:29:12,112 - octoprint.plugins.tracking - INFO - Sent tracking event startup, payload: {'python': '2.7.13', 'ram': 918188032, 'octopi_version': '0.16.0', 'version': u'1.3.10', 'pip': '19.0.1', 'cores': 4, 'freq': 1200.0, 'pi_model': 'Raspberry Pi 3 Model B Rev 1.2', 'os': 'linux'}
2019-03-15 01:29:24,127 - octoprint.server.preemptive_cache - INFO - ... done in 12.48s
2019-03-15 01:29:24,128 - octoprint.server.preemptive_cache - INFO - Preemptively caching / (ui _default) for {'query_string': 'l10n=en', 'path': '/', 'base_url': 'http://octopi.lan:2200/'}
2019-03-15 01:29:36,602 - octoprint.server.preemptive_cache - INFO - ... done in 12.47s
2019-03-15 01:29:36,603 - octoprint.server.preemptive_cache - INFO - Preemptively caching / (ui _default) for {'query_string': 'l10n=de', 'path': '/', 'base_url': 'http://octopi.lan/'}
2019-03-15 01:29:41,616 - octoprint.server.preemptive_cache - INFO - ... done in 5.01s

Searching the OctoPrint repository for 5000, I see this file which appears to be how the OctoPrint service is controlled.

haproxy is the translator from the default port 80 to whatever-it-is that OctoPrint's running on. So yes, you need to adjust that file which you did. But then you also need to make sure that OctoPrint is running on the port where you're redirecting it to.

1 Like

Thank you and I apologize for the delay in response.

In the end, I only had to change the back-end port like so and it worked.

Thank you for your time!

pi@octopi:/etc/default $ cat octoprint

# Configuration for /etc/init.d/octoprint

# The init.d script will only run if this variable non-empty.
OCTOPRINT_USER=pi

# To what host to bind daemon, default is 127.0.0.1
HOST=127.0.0.1

# On what port to run daemon, default is 5000
PORT=5011

# Path to the OctoPrint executable, use this to override the default setting "/usr/bin/octoprint"
DAEMON=/home/pi/oprint/bin/octoprint

# What arguments to pass to octoprint, usually no need to touch this
DAEMON_ARGS="--host=$HOST --port=$PORT"

# Umask of files octoprint generates, Change this to 000 if running octoprint as its own, separate user
UMASK=022

# Should we run at startup?
START=yes
1 Like