1
0
Fork 0
mirror of https://github.com/iiab/iiab.git synced 2025-02-13 03:32:12 +00:00

Merge pull request #851 from georgejhunt/izer

http://box/sugarizer fix on RPi & All OS's?  (Sugarizer 1.0+)
This commit is contained in:
A Holt 2018-08-22 23:11:12 -04:00 committed by GitHub
commit 4ae1be2fdd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 59 additions and 2 deletions

View file

@ -160,6 +160,13 @@
# chdir: "{{ sugarizer_location }}/sugarizer/server"
# when: internet_available and is_F18 and not node_modules_exists
# Add a nodejs express function that appends a prefix to urls
- name: Install path prefix proxy
command: npm install --allow-root --unsafe-perm=true path-prefix-proxy
args:
chdir: "{{ sugarizer_location }}/{{ sugarizer_server_version }}"
when: internet_available
# 5. PLACE CONFIG FILES
- name: Configure sugarizer.service (systemd), sugarizer.conf (Apache) and sugarizer.ini
@ -173,6 +180,7 @@
- { src: 'sugarizer.ini', dest: '{{ sugarizer_location }}/{{ sugarizer_server_version }}/env/sugarizer.ini', mode: '0644' }
- { src: 'sugarizer.conf', dest: '/etc/apache2/sites-available', mode: '0644' }
- { src: 'sugarizer.service.j2', dest: '/etc/systemd/system/sugarizer.service', mode: '0644' }
- { src: 'sugarizer.js', dest: '/opt/iiab/sugarizer-server', mode: '0644' }
- name: Create symlink for short URL http://box/sugarizer
file:
@ -189,6 +197,12 @@
state: restarted
daemon_reload: yes
when: sugarizer_enabled
- name: Restart Apache so http://box/sugarizer works (not just http://box:8089)
systemd:
name: apache2
state: restarted
when: sugarizer_enabled
- name: 'Disable+stop systemd service if sugarizer_enabled: False'
systemd:

View file

@ -1,2 +1,2 @@
RewriteEngine on
RewriteRule ^/sugarizer(.*)$ http://localhost:8089$1 [PT]
ProxyPass /sugarizer http://localhost:8089/sugarizer
ProxyPassReverse /sugarizer http://localhost:8089/sugarizer

View file

@ -0,0 +1,43 @@
// require files
var express = require('express'),
http = require('http'),
https = require('https'),
settings = require('./config/settings'),
common = require('./dashboard/helper/common');
ini = settings.load(),
app = express(),
server = null;
// init common
common.init(ini);
//configure app setting
require('./config/main')(app, ini);
// include api routes
require('./api/route')(app, ini);
// include dashboard routes
require('./dashboard/route')(app, ini);
// Handle https
if (ini.security.https) {
var credentials = common.loadCredentials(ini);
if (!credentials) {
console.log("Error reading HTTPS credentials");
process.exit(-1);
}
server = https.createServer(credentials, app);
} else {
server = http.createServer(app);
}
var pathPrefix = '/sugarizer';
app.use(pathPrefix, require('path-prefix-proxy')(pathPrefix));
// Start listening
server.listen(ini.web.port,"0.0.0.0");
console.log("Sugarizer Server is listening on"+(ini.security.https ? " secure":"")+" port " + ini.web.port + "...");
//export app for testing
module.exports = app;