1. Allow to work behind port forwarding
   - use request's port instead of hardcoded
2. Support deployemnt separately from SO:
   - add api_server as app parameter
   - remove unnecesary using on client side

Signed-off-by: Gennadiy Dubina <gennadiy.dubina@dataart.com>
diff --git a/skyquake/skyquake.js b/skyquake/skyquake.js
index b9af78a..726757f 100644
--- a/skyquake/skyquake.js
+++ b/skyquake/skyquake.js
@@ -83,6 +83,9 @@
 
 	var sslOptions = null;
 
+	var apiServer = argv['api-server'] ? argv['api-server'] : 'localhost';
+	var uploadServer = argv['upload-server'] ? argv['upload-server'] : null;
+
 	try {
 		if (argv['enable-https']) {
 			var keyFilePath = argv['keyfile-path'];
@@ -194,9 +197,16 @@
 		app.use(inactivity_routes);
 
 		// Configure global config with ssl enabled/disabled
-		configurationAPI.globalConfiguration.update({
-			ssl_enabled: httpsConfigured
-		});
+		var globalConfig = {
+			ssl_enabled: httpsConfigured,
+			api_server: apiServer
+		};
+
+		if (uploadServer) {
+			globalConfig.upload_server = uploadServer;
+		}
+
+		configurationAPI.globalConfiguration.update(globalConfig);
 
 		// Configure configuration route(s)
 		app.use(configuration_routes);