Skip to content

Commit 3f14c7d

Browse files
committed
separate dockerfile for node-red-test but added reverse proxy for /node-red-test
1 parent 40f8318 commit 3f14c7d

File tree

5 files changed

+236
-4
lines changed

5 files changed

+236
-4
lines changed

docker-compose.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,16 @@ services:
5050
depends_on:
5151
- mqtt
5252
restart: always
53+
environment:
54+
- httpRootEnv=noderedX
5355
node-red-test:
54-
build: node-red
56+
build: node-red-test
5557
ports:
5658
- "1882:1880"
5759
depends_on:
5860
- mqtt-test
61+
environment:
62+
- httpRootEnv=noderedX-test
5963
restart: always
6064
nginx:
6165
build : nginx

nginx/nginx.conf

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ http {
1717
proxy_pass http://grafana:3000;
1818
}
1919

20-
# /nodered will point to node-red (note that httpRoot must also be set to /nodered in settings.js of node-red)
21-
location /nodered {
20+
# /node-red will point to node-red (note that httpRoot must also be set to /node-red in settings.js of node-red)
21+
location /node-red {
2222
proxy_set_header Host $http_host;
2323
proxy_set_header X-Real-IP $remote_addr;
2424
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
@@ -28,6 +28,19 @@ http {
2828
proxy_set_header Connection "upgrade";
2929

3030
proxy_pass http://node-red:1880;
31+
}
32+
33+
# /node-red-test will point to node-red (note that httpRoot must also be set to /node-red-test in settings.js of node-red)
34+
location /node-red-test {
35+
proxy_set_header Host $http_host;
36+
proxy_set_header X-Real-IP $remote_addr;
37+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
38+
proxy_set_header X-Forwarded-Proto $scheme;
39+
proxy_http_version 1.1;
40+
proxy_set_header Upgrade $http_upgrade;
41+
proxy_set_header Connection "upgrade";
42+
43+
proxy_pass http://node-red-test:1880;
3144
}
3245
}
3346
}

node-red -test/Dockerfile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
FROM nodered/node-red-docker:rpi-v8
2+
3+
# installing an editor
4+
USER root
5+
RUN apt-get update && apt-get install nano
6+
USER node-red
7+
COPY ./settings.js /data/settings.js
8+
9+
RUN npm install node-red-contrib-resinio
10+
RUN npm install node-red-dashboard
11+
RUN npm install node-red-contrib-credentials

node-red -test/settings.js

Lines changed: 204 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,204 @@
1+
/* JVA 2018-10-28 */
2+
/**
3+
* Copyright 2013, 2016 IBM Corp.
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
**/
17+
18+
// The `https` setting requires the `fs` module. Uncomment the following
19+
// to make it available:
20+
//var fs = require("fs");
21+
22+
module.exports = {
23+
// the tcp port that the Node-RED web server is listening on
24+
uiPort: process.env.PORT || 1880,
25+
26+
// By default, the Node-RED UI accepts connections on all IPv4 interfaces.
27+
// The following property can be used to listen on a specific interface. For
28+
// example, the following would only allow connections from the local machine.
29+
//uiHost: "127.0.0.1",
30+
31+
// Retry time in milliseconds for MQTT connections
32+
mqttReconnectTime: 15000,
33+
34+
// Retry time in milliseconds for Serial port connections
35+
serialReconnectTime: 15000,
36+
37+
// Retry time in milliseconds for TCP socket connections
38+
//socketReconnectTime: 10000,
39+
40+
// Timeout in milliseconds for TCP server socket connections
41+
// defaults to no timeout
42+
//socketTimeout: 120000,
43+
44+
// Timeout in milliseconds for HTTP request connections
45+
// defaults to 120 seconds
46+
//httpRequestTimeout: 120000,
47+
48+
// The maximum length, in characters, of any message sent to the debug sidebar tab
49+
debugMaxLength: 1000,
50+
51+
// The file containing the flows. If not set, it defaults to flows_<hostname>.json
52+
//flowFile: 'flows.json',
53+
54+
// To enabled pretty-printing of the flow within the flow file, set the following
55+
// property to true:
56+
//flowFilePretty: true,
57+
58+
// By default, all user data is stored in the Node-RED install directory. To
59+
// use a different location, the following property can be used
60+
//userDir: '/home/nol/.node-red/',
61+
62+
// Node-RED scans the `nodes` directory in the install directory to find nodes.
63+
// The following property can be used to specify an additional directory to scan.
64+
//nodesDir: '/home/nol/.node-red/nodes',
65+
66+
// By default, the Node-RED UI is available at http://localhost:1880/
67+
// The following property can be used to specifiy a different root path.
68+
// If set to false, this is disabled.
69+
//httpAdminRoot: '/admin',
70+
71+
// Some nodes, such as HTTP In, can be used to listen for incoming http requests.
72+
// By default, these are served relative to '/'. The following property
73+
// can be used to specifiy a different root path. If set to false, this is
74+
// disabled.
75+
//httpNodeRoot: '/red-nodes',
76+
77+
// The following property can be used in place of 'httpAdminRoot' and 'httpNodeRoot',
78+
// to apply the same root to both parts.
79+
// JVA 2018-11-12: activated httpRoot
80+
httpRoot: '/node-red-test',
81+
82+
// When httpAdminRoot is used to move the UI to a different root path, the
83+
// following property can be used to identify a directory of static content
84+
// that should be served at http://localhost:1880/.
85+
//httpStatic: '/home/nol/node-red-static/',
86+
87+
// Securing Node-RED
88+
// -----------------
89+
// To password protect the Node-RED editor and admin API, the following
90+
// property can be used. See http://nodered.org/docs/security.html for details.
91+
//adminAuth: {
92+
// type: "credentials",
93+
// users: [{
94+
// username: "admin",
95+
// password: "$2a$08$zZWtXTja0fB1pzD4sHCMyOCMYz2Z6dNbM6tl8sJogENOMcxWV9DN.",
96+
// permissions: "*"
97+
// }]
98+
//},
99+
100+
adminAuth: {
101+
type: "credentials",
102+
users: [{
103+
username: process.env.USERNAME,
104+
password: process.env.PASSWORD,
105+
permissions: "*"
106+
}]
107+
},
108+
109+
110+
// To password protect the node-defined HTTP endpoints (httpNodeRoot), or
111+
// the static content (httpStatic), the following properties can be used.
112+
// The pass field is a bcrypt hash of the password.
113+
// See http://nodered.org/docs/security.html#generating-the-password-hash
114+
//httpNodeAuth: {user:"user",pass:"$2a$08$zZWtXTja0fB1pzD4sHCMyOCMYz2Z6dNbM6tl8sJogENOMcxWV9DN."},
115+
//httpStaticAuth: {user:"user",pass:"$2a$08$zZWtXTja0fB1pzD4sHCMyOCMYz2Z6dNbM6tl8sJogENOMcxWV9DN."},
116+
117+
// The following property can be used to enable HTTPS
118+
// See http://nodejs.org/api/https.html#https_https_createserver_options_requestlistener
119+
// for details on its contents.
120+
// See the comment at the top of this file on how to load the `fs` module used by
121+
// this setting.
122+
//
123+
//https: {
124+
// key: fs.readFileSync('privatekey.pem'),
125+
// cert: fs.readFileSync('certificate.pem')
126+
//},
127+
128+
// The following property can be used to disable the editor. The admin API
129+
// is not affected by this option. To disable both the editor and the admin
130+
// API, use either the httpRoot or httpAdminRoot properties
131+
//disableEditor: false,
132+
133+
// The following property can be used to configure cross-origin resource sharing
134+
// in the HTTP nodes.
135+
// See https://github.com/troygoode/node-cors#configuration-options for
136+
// details on its contents. The following is a basic permissive set of options:
137+
//httpNodeCors: {
138+
// origin: "*",
139+
// methods: "GET,PUT,POST,DELETE"
140+
//},
141+
142+
// If you need to set an http proxy please set an environment variable
143+
// called http_proxy (or HTTP_PROXY) outside of Node-RED in the operating system.
144+
// For example - http_proxy=http://myproxy.com:8080
145+
// (Setting it here will have no effect)
146+
// You may also specify no_proxy (or NO_PROXY) to supply a comma separated
147+
// list of domains to not proxy, eg - no_proxy=.acme.co,.acme.co.uk
148+
149+
// The following property can be used to add a custom middleware function
150+
// in front of all http in nodes. This allows custom authentication to be
151+
// applied to all http in nodes, or any other sort of common request processing.
152+
//httpNodeMiddleware: function(req,res,next) {
153+
// // Handle/reject the request, or pass it on to the http in node
154+
// // by calling next();
155+
// next();
156+
//},
157+
158+
// Anything in this hash is globally available to all functions.
159+
// It is accessed as context.global.
160+
// eg:
161+
// functionGlobalContext: { os:require('os') }
162+
// can be accessed in a function block as:
163+
// context.global.os
164+
165+
functionGlobalContext: {
166+
process: process,
167+
os: require('os')
168+
// octalbonescript:require('octalbonescript'),
169+
// jfive:require("johnny-five"),
170+
// j5board:require("johnny-five").Board({repl:false})
171+
},
172+
173+
// The following property can be used to order the categories in the editor
174+
// palette. If a node's category is not in the list, the category will get
175+
// added to the end of the palette.
176+
// If not set, the following default order is used:
177+
//paletteCategories: ['subflows', 'input', 'output', 'function', 'social', 'mobile', 'storage', 'analysis', 'advanced'],
178+
179+
editorTheme: {
180+
projects: {
181+
enabled: true
182+
}
183+
},
184+
185+
186+
// Configure the logging output
187+
logging: {
188+
// Only console logging is currently supported
189+
console: {
190+
// Level of logging to be recorded. Options are:
191+
// fatal - only those errors which make the application unusable should be recorded
192+
// error - record errors which are deemed fatal for a particular request + fatal errors
193+
// warn - record problems which are non fatal + errors + fatal errors
194+
// info - record information about the general running of the application + warn + error + fatal errors
195+
// debug - record information which is more verbose than info + info + warn + error + fatal errors
196+
// trace - record very detailed logging + debug + info + warn + error + fatal errors
197+
level: "info",
198+
// Whether or not to include metric events in the log output
199+
metrics: false,
200+
// Whether or not to include audit events in the log output
201+
audit: false
202+
}
203+
}
204+
}

node-red/settings.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ module.exports = {
7777
// The following property can be used in place of 'httpAdminRoot' and 'httpNodeRoot',
7878
// to apply the same root to both parts.
7979
// JVA 2018-11-12: activated httpRoot
80-
httpRoot: '/nodered',
80+
httpRoot: '/node-red',
8181

8282
// When httpAdminRoot is used to move the UI to a different root path, the
8383
// following property can be used to identify a directory of static content

0 commit comments

Comments
 (0)