Skip to content

Commit

Permalink
Support for secure protocols
Browse files Browse the repository at this point in the history
  • Loading branch information
KrisDavie committed Jun 7, 2018
1 parent 8c35236 commit 473524f
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 19 deletions.
4 changes: 3 additions & 1 deletion apache/apache.conf.js
Expand Up @@ -60,6 +60,8 @@ class ApacheConf {
tmp = tmp.replace(/SCOPE_X_SERVER_PORT/g, this._config.xPort)
tmp = tmp.replace(/APACHE_LOG_DIR/g, this._config.apacheLogDir)
tmp = tmp.replace(/APACHE_HTML_DIR/g, this._config.apacheHtmlDir)
tmp = tmp.replace(/HTTP_PROTOCOL/g, this._config.httpProtocol)
tmp = tmp.replace(/WS_PROTOCOL/g, this._config.wsProtocol)
fs.writeFile(this.apacheSCopeConfigFilePath, tmp, 'utf8', (err) => {
if (err) {
console.log(err)
Expand All @@ -80,4 +82,4 @@ class ApacheConf {

}

exports.ApacheConf = ApacheConf
exports.ApacheConf = ApacheConf
3 changes: 2 additions & 1 deletion apache/config.json
@@ -1,7 +1,8 @@
{
"debug": true,
"domainName": "",
"protocol": "http",
"httpProtocol": "http",
"wsProtocol": "ws",
"mPort": "55850",
"pPort": "55851",
"xPort": "55852",
Expand Down
16 changes: 8 additions & 8 deletions apache/template.conf
Expand Up @@ -8,29 +8,29 @@
<VirtualHost *:80>
DocumentRoot APACHE_HTML_DIR
ServerName SCOPE_SERVER_DOMAIN_NAME
ServerAlias "http://SCOPE_SERVER_DOMAIN_NAME"
ServerAlias "HTTP_PROTOCOL://SCOPE_SERVER_DOMAIN_NAME"

ProxyRequests Off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
<LocationMatch ^/sockjs-node/.*/websocket>
ProxyPass ws://SCOPE_SERVERS_HOSTNAME:SCOPE_X_SERVER_PORT/
ProxyPassReverse ws://SCOPE_SERVERS_HOSTNAME:SCOPE_X_SERVER_PORT/
ProxyPass WS_PROTOCOL://SCOPE_SERVERS_HOSTNAME:SCOPE_X_SERVER_PORT/
ProxyPassReverse WS_PROTOCOL://SCOPE_SERVERS_HOSTNAME:SCOPE_X_SERVER_PORT/
</LocationMatch>
<Location /upload/>
ProxyPass http://SCOPE_SERVERS_HOSTNAME:SCOPE_P_SERVER_PORT/
ProxyPassReverse http://SCOPE_SERVERS_HOSTNAME:SCOPE_P_SERVER_PORT/
ProxyPass HTTP_PROTOCOL://SCOPE_SERVERS_HOSTNAME:SCOPE_P_SERVER_PORT/
ProxyPassReverse HTTP_PROTOCOL://SCOPE_SERVERS_HOSTNAME:SCOPE_P_SERVER_PORT/
</Location>
<Location /protobuf/>
ProxyPass ws://SCOPE_SERVERS_HOSTNAME:SCOPE_X_SERVER_PORT/
ProxyPassReverse ws://SCOPE_SERVERS_HOSTNAME:SCOPE_X_SERVER_PORT/
ProxyPass WS_PROTOCOL://SCOPE_SERVERS_HOSTNAME:SCOPE_X_SERVER_PORT/
ProxyPassReverse WS_PROTOCOL://SCOPE_SERVERS_HOSTNAME:SCOPE_X_SERVER_PORT/
</Location>

# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
ErrorLog APACHE_LOG_DIR/scope-http-error.log
CustomLog APACHE_LOG_DIR/scope-http-access.log combined
</VirtualHost>
</VirtualHost>
3 changes: 2 additions & 1 deletion config.json
@@ -1,7 +1,8 @@
{
"debug": true,
"domainName": "127.0.0.1",
"protocol": "http",
"httpProtocol": "http",
"wsProtocol": "ws",
"mPort": "55850",
"pPort": "55851",
"xPort": "55852",
Expand Down
2 changes: 1 addition & 1 deletion src/components/AppSidebar.jsx
Expand Up @@ -265,7 +265,7 @@ class AppSidebar extends Component {
}

let xhr = new XMLHttpRequest();
xhr.open("POST", BACKEND.protocol + "://" + BACKEND.host + ":" + this.XHRport + "/");
xhr.open("POST", BACKEND.httpProtocol + "://" + BACKEND.host + ":" + this.XHRport + "/");
xhr.responseType = 'blob';

xhr.upload.addEventListener('load', (event) => {
Expand Down
4 changes: 2 additions & 2 deletions src/components/common/API.jsx
Expand Up @@ -19,9 +19,9 @@ class API {

try {
if(REVERSEPROXYON) {
this.GBCConnection = new this.GBC("ws://" + FRONTEND.host + "/protobuf/", 'src/proto/s.proto', { scope: { Main: BACKEND.host + ":" + this.RPCport } }).connect();
this.GBCConnection = new this.GBC(FRONTEND.wsProtocol + "://" + FRONTEND.host + "/protobuf/", 'src/proto/s.proto', { scope: { Main: BACKEND.host + ":" + this.RPCport } }).connect();
} else {
this.GBCConnection = new this.GBC("ws://" + BACKEND.host + ":" + this.WSport + "/", 'src/proto/s.proto', { scope: { Main: BACKEND.host + ":" + this.RPCport } }).connect();
this.GBCConnection = new this.GBC(BACKEND.wsProtocol + "://" + BACKEND.host + ":" + this.WSport + "/", 'src/proto/s.proto', { scope: { Main: BACKEND.host + ":" + this.RPCport } }).connect();
}
console.log(this.GBCConnection)
this.connected = true;
Expand Down
4 changes: 2 additions & 2 deletions src/components/common/Uploader.jsx
Expand Up @@ -20,9 +20,9 @@ export default class Uploader {

let xhr = new XMLHttpRequest();
if(REVERSEPROXYON) {
xhr.open("POST", FRONTEND.protocol +"://" + FRONTEND.host + "/upload/")
xhr.open("POST", FRONTEND.httpProtocol +"://" + FRONTEND.host + "/upload/")
} else {
xhr.open("POST", BACKEND.protocol + "://" + BACKEND.host + ":" + this.XHRport + "/");
xhr.open("POST", BACKEND.httpProtocol + "://" + BACKEND.host + ":" + this.XHRport + "/");
}
xhr.upload.addEventListener('progress', (event) => {
if (DEBUG) console.log("Data uploaded: " + event.loaded + "/" + event.total);
Expand Down
8 changes: 5 additions & 3 deletions webpack.config.js
Expand Up @@ -5,7 +5,7 @@ var fs = require('fs')
var pkg = require('./package.json')
const UglifyJsPlugin = require("uglifyjs-webpack-plugin");
// Import config file
let isAWS = process.env.NODE_TYPE == "aws"
let isAWS = process.env.NODE_TYPE == "aws"
let _config = null
if(isAWS) {
_config = require('./apache/config.json');
Expand Down Expand Up @@ -64,14 +64,16 @@ let config = {
token: "8422dd882b60604d327939997448dd1b5c61f54e"
}),
BACKEND: JSON.stringify({
protocol: _config.protocol,
httpProtocol: _config.httpProtocol,
wsProtocol: _config.wsProtocol,
host: "127.0.0.1",
WSport: _config.xPort,
XHRport: _config.pPort,
RPCport: _config.gPort
}),
FRONTEND: JSON.stringify({
protocol: _config.protocol,
httpProtocol: _config.httpProtocol,
wsProtocol: _config.wsProtocol,
host: _config.domainName
})
}),
Expand Down

0 comments on commit 473524f

Please sign in to comment.