mirror of
https://github.com/iiab/iiab.git
synced 2025-02-13 11:42:08 +00:00
Merge pull request #1476 from m-anish/nodered-reverse-proxy
Node-RED reverse proxy — for http://box/nodered
This commit is contained in:
commit
0d51ccf653
6 changed files with 70 additions and 10 deletions
|
@ -14,7 +14,7 @@ Prior to installing IIAB, make sure your `/etc/iiab/local_vars.yml <http://wiki.
|
|||
nodered_install: True
|
||||
nodered_enabled: True
|
||||
|
||||
After installing Node-RED as part IIAB, please log in to http://box:1880 with:
|
||||
After installing Node-RED as part IIAB, please log in to http://box/nodered or http://box.lan:1880 with:
|
||||
|
||||
Username: ``Admin``
|
||||
|
||||
|
|
|
@ -1,5 +1,11 @@
|
|||
nodered_install: False
|
||||
nodered_enabled: False
|
||||
# nodered_install: False
|
||||
# nodered_enabled: False
|
||||
# nodered_port: 1880
|
||||
|
||||
# All above are set in: github.com/iiab/iiab/blob/master/vars/default_vars.yml
|
||||
# If nec, change them by editing /etc/iiab/local_vars.yml prior to installing!
|
||||
|
||||
nodered_web_path: nodered # http://box/nodered redirect to http://box:1880
|
||||
|
||||
nodered_user: Admin
|
||||
nodered_password: changeme
|
||||
|
|
|
@ -46,14 +46,60 @@
|
|||
mode: 0666
|
||||
when: nodered_install
|
||||
|
||||
- name: Enable & Start node-red service
|
||||
- name: Install Apache's sites-available/nodered.conf from template
|
||||
template:
|
||||
backup: yes
|
||||
src: nodered.conf.j2
|
||||
dest: /etc/apache2/sites-available/nodered.conf
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0666
|
||||
when: nodered_install
|
||||
|
||||
- name: Create symlink nodered.conf from sites-enabled to sites-available, for short URL http://box/nodered (if nodered_enabled)
|
||||
file:
|
||||
src: /etc/apache2/sites-available/nodered.conf
|
||||
dest: /etc/apache2/sites-enabled/nodered.conf
|
||||
owner: root
|
||||
group: root
|
||||
state: link
|
||||
when: nodered_enabled
|
||||
|
||||
- name: Remove symlink /etc/apache2/sites-enabled/nodered.conf (if not nodered_enabled)
|
||||
file:
|
||||
path: /etc/apache2/sites-enabled/nodered.conf
|
||||
state: absent
|
||||
when: not nodered_enabled
|
||||
|
||||
- name: Enable proxy_wstunnel apache2 module
|
||||
apache2_module:
|
||||
state: present
|
||||
name: proxy_wstunnel
|
||||
when: nodered_install
|
||||
|
||||
- name: Restart Apache service ({{ apache_service }}) to enable/disable http://box/nodered (not just http://box:{{ nodered_port }})
|
||||
systemd:
|
||||
daemon_reload: yes
|
||||
name: "{{ apache_service }}" # httpd or apache2
|
||||
state: restarted
|
||||
when: nodered_install
|
||||
|
||||
- name: Enable & (Re)start 'node-red' systemd service (if nodered_enabled)
|
||||
systemd:
|
||||
daemon_reload: yes
|
||||
name: node-red
|
||||
enabled: yes
|
||||
state: started
|
||||
state: restarted
|
||||
when: nodered_enabled
|
||||
|
||||
- name: Disable & Stop 'node-red' systemd service (if not nodered_enabled)
|
||||
systemd:
|
||||
daemon_reload: yes
|
||||
name: node-red
|
||||
enabled: no
|
||||
state: stopped
|
||||
when: not nodered_enabled
|
||||
|
||||
- name: Add 'nodered' variable values to {{ iiab_ini_file }}
|
||||
ini_file:
|
||||
path: "{{ iiab_ini_file }}"
|
||||
|
|
6
roles/nodered/templates/nodered.conf.j2
Normal file
6
roles/nodered/templates/nodered.conf.j2
Normal file
|
@ -0,0 +1,6 @@
|
|||
ProxyPreserveHost On
|
||||
ProxyRequests Off
|
||||
ProxyPass /{{ nodered_web_path }}/debug/ws ws://localhost:{{ nodered_port }}/{{ nodered_web_path }}/debug/ws
|
||||
ProxyPass /{{ nodered_web_path }}/comms ws://localhost:{{ nodered_port }}/{{ nodered_web_path }}/comms
|
||||
ProxyPass /{{ nodered_web_path }} http://localhost:{{ nodered_port }}/{{ nodered_web_path }}
|
||||
ProxyPassReverse /{{ nodered_web_path }} http://localhost:{{ nodered_port }}/{{ nodered_web_path }}
|
|
@ -96,7 +96,7 @@ module.exports = {
|
|||
|
||||
// The following property can be used in place of 'httpAdminRoot' and 'httpNodeRoot',
|
||||
// to apply the same root to both parts.
|
||||
//httpRoot: '/red',
|
||||
httpRoot: '/{{ nodered_web_path }}',
|
||||
|
||||
// When httpAdminRoot is used to move the UI to a different root path, the
|
||||
// following property can be used to identify a directory of static content
|
||||
|
|
|
@ -229,14 +229,14 @@
|
|||
# # Use this instead, if tabs are truly nec:
|
||||
# # block: "\tvar pathPrefix = '/sugarizer';\n\tapp.use(pathPrefix, require('path-prefix-proxy')(pathPrefix));"
|
||||
|
||||
- name: Create symlink sugarizer.conf from sites-enabled to sites-available, for short URL http://box/sugarizer (debuntu)
|
||||
- name: Create symlink sugarizer.conf from sites-enabled to sites-available, for short URLs http://box/sugar & http://box/sugarizer (if sugarizer_enabled)
|
||||
file:
|
||||
src: /etc/apache2/sites-available/sugarizer.conf
|
||||
path: /etc/apache2/sites-enabled/sugarizer.conf
|
||||
state: link
|
||||
when: sugarizer_enabled and is_debuntu
|
||||
|
||||
- name: "Remove symlink /etc/apache2/sites-enabled/sugarizer.conf, if sugarizer_enabled: False (debuntu)"
|
||||
- name: Remove symlink /etc/apache2/sites-enabled/sugarizer.conf (if not sugarizer_enabled)
|
||||
file:
|
||||
path: /etc/apache2/sites-enabled/sugarizer.conf
|
||||
state: absent
|
||||
|
@ -245,7 +245,8 @@
|
|||
|
||||
# 6. RESTART/STOP SYSTEMD SERVICE
|
||||
|
||||
- name: Enable & Restart systemd service if sugarizer_enabled, with "systemctl daemon-reload" (in case mongodb.service changed?)
|
||||
# with "systemctl daemon-reload" in case mongodb.service changed, etc
|
||||
- name: Enable & Restart 'sugarizer' systemd service (if sugarizer_enabled)
|
||||
systemd:
|
||||
name: sugarizer
|
||||
daemon_reload: yes
|
||||
|
@ -253,9 +254,10 @@
|
|||
state: restarted
|
||||
when: sugarizer_enabled
|
||||
|
||||
- name: "Disable systemd service, if sugarizer_enabled: False"
|
||||
- name: Disable & Stop 'sugarizer' systemd service (if not sugarizer_enabled)
|
||||
systemd:
|
||||
name: sugarizer
|
||||
daemon_reload: yes
|
||||
enabled: no
|
||||
state: stopped
|
||||
when: not sugarizer_enabled
|
||||
|
|
Loading…
Reference in a new issue