Deprecated: Creation of dynamic property Timber\Site::$pingback is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Site.php on line 180

Deprecated: Creation of dynamic property Timber\User::$name is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/User.php on line 118

Deprecated: Creation of dynamic property Timber\Post::$_edit_lock is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_edit_last is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$onesignal_meta_box_present is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$onesignal_send_notification is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$onesignal_modify_title_and_content is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$onesignal_notification_custom_heading is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$onesignal_notification_custom_content is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_yoast_wpseo_estimated-reading-time-minutes is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_yoast_wpseo_wordproof_timestamp is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$tipologia is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_tipologia is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$attributi is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_attributi is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$in_evidenza_newsletter is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_in_evidenza_newsletter is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$inviato_in_newsletter is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_inviato_in_newsletter is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_yoast_wpseo_primary_category is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_yoast_wpseo_primary_content_type is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_yoast_wpseo_primary_attributes is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_yoast_wpseo_primary_speciali is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_yoast_wpseo_content_score is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_yoast_wpseo_focuskw is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_yoast_wpseo_linkdex is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_yoast_wpseo_metadesc is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_thumbnail_id is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$response_body is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$status is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$post_date_gmt is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$comment_status is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$ping_status is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$post_password is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$post_name is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$to_ping is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$pinged is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$post_modified is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$post_modified_gmt is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$post_content_filtered is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$guid is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$menu_order is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$post_mime_type is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$comment_count is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$filter is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71
Tunnel Cloudflare: come superare il firewall | IlSoftware.it

Tunnel Cloudflare: come superare il firewall

I tunnel Cloudflare possono essere utilizzati non soltanto per esporre servizi HTTP e HTTPS ma anche altre funzionalità superando qualunque firewall. Ecco come è possibile fare.

Tra i vari servizi messi a disposizione dal noto fornitore statunitense ci sono anche i tunnel Cloudflare, uno strumento molto utile che consente di creare connessioni sicure e private tra una macchina locale e il servizio Cloudflare. In questo modo è possibile instradare il traffico di rete attraverso l’infrastruttura Cloudflare, garantendo sicurezza, affidabilità e prestazioni ottimali.

Per utilizzare i tunnel Cloudflare, è necessario installare l’utility cloudflared. Essa funge da client per stabilire e gestire la connessione al servizio Cloudflare, previa autenticazione.

Il tunnel che viene creato è un canale sicuro che garantisce sicurezza e prestazioni. Il traffico, infatti, è crittografato e protetto ricorrendo a funzionalità di sicurezza avanzate come il Web Application Firewall (WAF) e il filtro anti-DDoS.

I tunnel cloudflared sono comunemente usati per “pubblicare” un server web che è in esecuzione a valle di un firewall. Di default, Cloudflare limita il traffico ai pacchetti dati HTTP/HTTPS non consentendo l’esposizione di altri servizi.

Nell’articolo Tunnel via Cloudflare to any TCP Service si spiega come rendere accessibile dalla rete Internet qualunque servizio su uno o più sistemi protetti da firewall. Nei due esempi si prende in considerazione, a mero titolo esemplificativo, SSHD (Secure Shell Daemon) ovvero l’applicazione che implementa il protocollo SSH per consentire l’accesso remoto sicuro a un server o a un sistema Unix-like. SSHD è il daemon (questo significa l’ultima lettera del nome…) che gestisce le connessioni SSH in entrata e in uscita sul server.

Attraverso l’uso di SSHD, gli utenti possono accedere a distanza e in modo sicuro a un sistema remoto tramite la rete, eseguire comandi, trasferire file e svolgere altre attività di gestione del sistema. Le connessioni SSH sono ampiamente utilizzate per l’amministrazione remota dei sistemi e per la gestione delle risorse di rete.

Grazie al tunneling Cloudflare, per “pubblicare” in rete qualsiasi altro servizio è possibile aggiungere un proxy WebSocket su entrambi i lati del tunnel.

Cos’è e come funziona un proxy WebSocket

WebSocket è un protocollo di comunicazione bidirezionale full-duplex che consente una comunicazione efficiente e persistente tra un client Web e un server. Un proxy WebSocket funge da intermediario tra il client e il server, gestendo e inoltrando le richieste e le risposte WebSocket.

Quando un client WebSocket si connette a un server WebSocket tramite un proxy, la richiesta viene instradata attraverso il proxy che agisce come un punto di accesso esterno per il server. Il proxy può eseguire diverse operazioni come la verifica delle autorizzazioni, il controllo degli accessi, il filtraggio dei contenuti e il logging delle attività.

Il proxy WebSocket può essere configurato per bilanciare il carico delle connessioni WebSocket su più server: in questo modo è possibile distribuire il carico di lavoro in modo equo tra i server, migliorando le prestazioni e la scalabilità del sistema. Sono inoltre previste e attivabili funzionalità di caching, compressione dei dati, crittografia e gestione delle sessioni.

Esporre un servizio in rete tramite tunnel Cloudflare e websocat

websocat è un software open source che permette di creare connessioni WebSocket dalla riga di comando. Offre una vasta gamma di funzionalità e consente di comunicare con un server WebSocket in modo semplice ed efficace risultando utile, come vedremo anche in questo articolo, in molteplici situazioni.

I comandi riportati nel primo esempio in questa pagina, permettono di creare un tunnel tra il server posto dietro al firewall e i sistemi Cloudflare.

Il primo comando websocat -E -b ws-l:127.0.0.1:40008 tcp:127.0.0.1:22 crea un WebSocket in ascolto sull’indirizzo IP 127.0.0.1 sulla porta 40008 e inoltra tutti i dati ricevuti alla porta TCP 22 sulla stessa macchina. La porta TCP 22 è in questo caso utilizzata dal servizio SSHD in esecuzione sul server.

Il secondo comando cloudflared tunnel --url http://localhost:40008 --no-autoupdate crea un tunnel utilizzando cloudflared. Questo comando consente di creare un tunnel tra il server WebSocket locale in esecuzione all’indirizzo http://localhost:40008 e il servizio Cloudflare Tunnel. Cloudflared si occupa di stabilire la connessione sicura tra il server locale e il servizio Cloudflare.

Dopo aver impartito i due comandi lato server, viene mostrato un URL HTTPS che punta al dominio trycloudflare.com.

I successivi comandi websocat -E -b tcp-l:127.0.0.1:2222 ws://url-personalizzato.trycloudflare.com e ssh -p 2222 root@127.0.0.1 permettono di creare un tunnel WebSocket tra un dispositivo client e l’endpoint su Cloudflare. Il tunnel diventa quindi immediatamente sfruttabile per stabilire una connessione SSH al server remoto (tramite l’utente root).

Accesso remoto senza limiti con un proxy SOCKS5

Nel secondo esempio riportato nella pagina citata in apertura, viene suggerito l’utilizzo dello strumento gost (GO Simple Tunnel). Con questo approccio alternativo, grazie all’impiego di un proxy SOCKS 5, diventa possibile accedere a qualunque risorsa: qualsiasi host all’interno della LAN e qualsiasi host sulla rete Internet.

gost è un software open source scritto nel linguaggio Go che consente di creare tunnel crittografati tra diversi host utilizzando vari protocolli di tunneling, come SOCKS5, HTTP o TCP.

Il progetto gost vuole infatti assicurare un’alternativa leggera e semplice per la creazione di tunnel cifrati. Supporta la crittografia tramite protocolli come TLS (Transport Layer Security) e ha la capacità di mascherare il traffico per renderlo più difficile da rilevare o bloccare.

SOCKS5 è un tipo di proxy che consente il routing delle connessioni Internet attraverso un server intermedio. Funziona come un intermediario tra il client e il server di destinazione, consentendo al client di indirizzare le richieste verso il server tramite proxy.

Sul server posto dietro al firewall si possono ad esempio usare i comandi che seguono:

gost -L mws://:40009 &
cloudflared tunnel --url http://localhost:40009 --no-autoupdate

Il comando gost avvia un server WebSocket in ascolto sulla porta 40009. Il server WebSocket ascolta le connessioni in entrata sulla porta specificata e inoltra il traffico verso la destinazione indicata. Il secondo comando, invece, crea un tunnel sicuro attraverso Cloudflare verso l’URL riportato.

Sulla postazione di lavoro remota basta utilizzare gost -L :1080 -F 'mwss://url-personalizzato.trycloudflare.com:443' per stabilire un collegamento.

Da ultimo, è importante evidenziare che il servizio di tunneling gratuito Cloudflare basato sull’utilizzo di WebSocket limita il numero di connessioni che possono essere stabilite.

L’immagine in apertura è tratta da Ridiculously easy to use Tunnels (Cloudflare).

Ti consigliamo anche

Link copiato negli appunti