I have two machines:
- Public web server - Apache 2.4, Ubuntu (eg. 194.204.159.1 domain.net)
- Private server - RabbitMQ server + Web Socket, Ubuntu (eg. 192.168.0.10)
I need to configure Apache 2.4 on server 1. as Reverse Proxy for communication with Web Socket server 2. Server 1. is connected with server 2.
On server 1. I have a Javascript script that should get a messages from queue from server 2. via Web Socket (RabbitMQ Web MQTT Plugin).
<script src="https://cdnjs.cloudflare.com/ajax/libs/paho-mqtt/1.0.1/mqttws31.min.js" type="text/javascript"></script>
<script>
var wsbroker = location.hostname;
var wsport = 15675;
var client = new Paho.MQTT.Client(wsbroker, wsport, "/ws",
"myclientid_" + parseInt(Math.random() * 100, 10));
client.onConnectionLost = function (responseObject) {
console.log("CONNECTION LOST - " + responseObject.errorMessage);
};
client.onMessageArrived = function (message) {
console.log("RECEIVE ON " + message.destinationName + " PAYLOAD " + message.payloadString);
};
var options = {
timeout: 5,
useSSL: true,
userName: 'websocket',
password: 'websocket',
onSuccess: function () {
console.log("CONNECTION SUCCESS");
client.subscribe('/vhost/mqtt-queue', {qos: 0});
},
onFailure: function (message) {
console.log("CONNECTION FAILURE - " + message.errorMessage);
}
};
</script>