diff --git a/dicos/91_ninegate.xml b/dicos/91_ninegate.xml index e5d79b90..38174567 100644 --- a/dicos/91_ninegate.xml +++ b/dicos/91_ninegate.xml @@ -2,6 +2,7 @@ + @@ -9,6 +10,7 @@ ninegate-apps + @@ -18,11 +20,6 @@ ninegate - - - ninegate_websocket_portexterne - - @@ -372,19 +369,6 @@ - - - - - - 5555 - - - 5556 - - - - @@ -441,7 +425,7 @@ Paramètres associés à Roundcube Paramètres associés à Sacoche Paramètres associés à Wordpress - Paramètres associés au Serveur WEBSOCKET + Paramètres associés au Serveur WEBSOCKET Paramètres associés aux Mails Paramètres EoleDB associés à Ninegate @@ -453,6 +437,11 @@ activer_ninegate + + non + nineboard_nginx + + non @@ -529,6 +518,7 @@ ninegate_dbpass ninegate + ninegate_nginx ninegate-migration ninegate @@ -796,25 +786,6 @@ ninegate_widsacoche_syncenvole - - - - non - - ninegate_websocket_url - ninegate_websocket_portinterne - ninegate_websocket_portexterne - ninegate_websocket - - - - oui - activer_apache - web_url - None - - - oui diff --git a/src/ninegate-1.0/app/config/config.yml b/src/ninegate-1.0/app/config/config.yml index cf384f23..e323438c 100644 --- a/src/ninegate-1.0/app/config/config.yml +++ b/src/ninegate-1.0/app/config/config.yml @@ -127,16 +127,16 @@ gos_web_socket: firewall: main shared_config: true server: - port: %websocket_port% #The port the socket server will listen on - host: %websocket_host% #The host ip to bind to + port: 443 #The port the socket server will listen on + host: %weburl%/wssninegate #The host ip to bind to router: resources: - "@CadolesWebsocketBundle/Resources/config/topic.yml" pushers: wamp: - host: %websocket_host% - port: %websocket_portinterne% + host: 0.0.0.0 + port: 5556 # ckeditor configuration ivory_ck_editor: diff --git a/src/ninegate-1.0/scripts/ninegate-websocket.sh b/src/ninegate-1.0/scripts/ninegate-websocket.sh index 2f8fc83b..f154bf97 100755 --- a/src/ninegate-1.0/scripts/ninegate-websocket.sh +++ b/src/ninegate-1.0/scripts/ninegate-websocket.sh @@ -1,11 +1,9 @@ #!/bin/bash -websocket_url=$(CreoleGet adresse_ip_eth0 non) -websocket_portinterne=$(CreoleGet ninegate_websocket_portinterne non) # Server Websocket if [[ "$1" != "restartifdown" ]]; then echo WEBSOCKET = STOP - pid="$(pgrep -a -f gos:websocket | grep $websocket_portinterne)" + pid="$(pgrep -a -f gos:websocket | grep 5556)" if [ -n "${pid}" ]; then IFS=' ' read -r -a array <<< "$pid" kill -9 ${array[0]}; @@ -13,7 +11,7 @@ if [[ "$1" != "restartifdown" ]]; then fi # Port LISTEN ? -pid="$(pgrep -a -f gos:websocket | grep $websocket_portinterne)" +pid="$(pgrep -a -f gos:websocket | grep 5556)" restart="yes" if [ "$1" == "restartifdown" ] && [ -n "${pid}" ] ; then restart="no" @@ -22,5 +20,5 @@ fi if [ "$restart" == "yes" ] && [ "$1" != "stop" ] ; then echo WEBSOCKET = START cd /var/www/html/ninegate - bin/console gos:websocket:server --port $websocket_portinterne -a $websocket_url --no-debug -n -q --env=prod & disown + systemctl restart wssninegate fi \ No newline at end of file diff --git a/src/ninegate-1.0/src/Cadoles/PortalBundle/Resources/views/Page/pages.html.twig b/src/ninegate-1.0/src/Cadoles/PortalBundle/Resources/views/Page/pages.html.twig index a7e4c9cb..274c0356 100644 --- a/src/ninegate-1.0/src/Cadoles/PortalBundle/Resources/views/Page/pages.html.twig +++ b/src/ninegate-1.0/src/Cadoles/PortalBundle/Resources/views/Page/pages.html.twig @@ -318,49 +318,6 @@ loadmsgCounter() }, {{(app.session.get("timerefreshnotif")*1000)}}); {% endif %} - - // Init socket de counter - /* Désactiver car il semble préférable de faire un appel ajax régulier plutot qu'ouvrir un channel websocket - {% if websocket_activate %} - var _WS_URI = "wss://{{ gos_web_socket_server_host }}:{{ gos_web_socket_server_port }}"; - - var webSocket = WS.connect(_WS_URI); - - webSocket.on("socket/connect", function (session) { - // The callback function in "subscribe" is called everytime an event is published in that channel. - session.subscribe("websocket/counter", function (uri, payload) { - if(payload.log) { - console.log("Received message", payload.log); - } - if(payload.alert) { - alert(payload.alert); - } - {% if app.user %} - if(payload.from!="{{app.user.id}}") { - menu=$("a[data-group='"+payload.group+"']"); - if(menu.length) { - if(payload.add) { - console.log("Ajout counter pour group "+payload.group+" by "+payload.from); - if(menu.children(".badge").length) { - menu.children(".badge").html(+(menu.children(".badge").html())+1); - } - else menu.append("1getRepository("CadolesCoreBundle:UserGroup")->findOneBy(["group"=>$group,"user"=>$user]); + $key=null; if($usergroup) { - $usergroup->setKeyvalue($key); - $em->persist($usergroup); - $em->flush(); + $key=$usergroup->getKeyvalue(); + if(is_null($key)) { + $key = Uuid::uuid4(); + $usergroup->setKeyvalue($key); + $em->persist($usergroup); + $em->flush(); + } } diff --git a/src/ninegate-1.0/src/Cadoles/WebsocketBundle/Resources/views/Chat/client.html.twig b/src/ninegate-1.0/src/Cadoles/WebsocketBundle/Resources/views/Chat/client.html.twig index 10a787d9..eb83b1e0 100644 --- a/src/ninegate-1.0/src/Cadoles/WebsocketBundle/Resources/views/Chat/client.html.twig +++ b/src/ninegate-1.0/src/Cadoles/WebsocketBundle/Resources/views/Chat/client.html.twig @@ -362,7 +362,8 @@ function websocket() { - var _WS_URI = "wss://{{ gos_web_socket_server_host }}:{{ gos_web_socket_server_port }}"; + var _WS_URI = "wss://{{ gos_web_socket_server_host }}"; + console.log(_WS_URI); webSocket = WS.connect(_WS_URI,{retryDelay: delayRetry}); webSocket.on("socket/connect", function (sess) { diff --git a/tmpl/ninegate-apache.conf b/tmpl/ninegate-apache.conf index 5a4706fb..9eea00a7 100644 --- a/tmpl/ninegate-apache.conf +++ b/tmpl/ninegate-apache.conf @@ -9,23 +9,6 @@ Alias /ninegate /var/www/html/ninegate/web %if %%getVar("ninegate_activate_websocket", 'non') == "oui" -Listen %%adresse_ip_eth0:%%ninegate_websocket_portexterne - - ErrorLog /var/log/apache2/ssl_error.log - CustomLog /var/log/apache2/ssl_access.log common - SSLEngine on - %if %%cert_type == "letsencrypt" - SSLCertificateFile /etc/ssl/letsencrypt/conf/live/%%ninegate_websocket_url/cert.pem - SSLCertificateKeyFile /etc/ssl/letsencrypt/conf/live/%%ninegate_websocket_url/privkey.pem - %else - SSLCertificateFile %%server_cert - SSLCertificateKeyFile %%server_key - %end if - SSLProtocol all -SSLv3 -SSLv2 - ServerName %%ninegate_websocket_url - RewriteEngine On - - ProxyPass / ws://%%adresse_ip_eth0:%%ninegate_websocket_portinterne retry=0 keepalive=On - ProxyPassReverse / ws://%%adresse_ip_eth0:%%ninegate_websocket_portinterne retry=0 - +ProxyPass /wssninegate ws://0.0.0.0:5556 retry=0 keepalive=On +ProxyPassReverse /wssninegate ws://0.0.0.0:5556 retry=0 %end if \ No newline at end of file diff --git a/tmpl/ninegate-nginx.conf b/tmpl/ninegate-nginx.conf new file mode 100644 index 00000000..9b9eb851 --- /dev/null +++ b/tmpl/ninegate-nginx.conf @@ -0,0 +1,6 @@ + location /wssninegate { + proxy_pass https://%%container_ip_web; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + } \ No newline at end of file diff --git a/tmpl/ninegate-template.yml b/tmpl/ninegate-template.yml index 9d671595..012d46ed 100644 --- a/tmpl/ninegate-template.yml +++ b/tmpl/ninegate-template.yml @@ -52,14 +52,8 @@ parameters: %end if %if %%getVar("ninegate_activate_websocket", 'non') == "oui" websocket_activate: true - websocket_host: %%ninegate_websocket_url - websocket_port: %%ninegate_websocket_portexterne - websocket_portinterne: %%ninegate_websocket_portinterne %else websocket_activate: false - websocket_host: %%web_url - websocket_port: 80 - websocket_portinterne: 80 %end if %if %%getVar("ninegate_activate_portal", 'non') == "oui" portal_activate: true diff --git a/tmpl/ninegate.service b/tmpl/ninegate.service new file mode 100644 index 00000000..4c042b2c --- /dev/null +++ b/tmpl/ninegate.service @@ -0,0 +1,11 @@ +[Unit] +Description=Ninegate websocket server +After=local-fs.target network.target + +[Service] +Type=simple +ExecStart=/var/www/html/ninegate/bin/console gos:websocket:server --port 5556 -a 0.0.0.0 --no-debug -n -q --env=prod +Restart=on-watchdog + +[Install] +WantedBy=multi-user.target