Skip to content

Instantly share code, notes, and snippets.

@MrAkaki
Last active January 24, 2022 09:56
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save MrAkaki/bd3fa88ce4e7f9165da038e74673b1f6 to your computer and use it in GitHub Desktop.
Save MrAkaki/bd3fa88ce4e7f9165da038e74673b1f6 to your computer and use it in GitHub Desktop.
Apache proxy ssl thingsboard
<VirtualHost *:443>
ServerAdmin "EMAIL ADMIN"
DocumentRoot /var/www/html
ServerName "SERVERNAME"
ProxyRequests off
ProxyPreserveHost On
#Redireccion de wss a ws
RewriteEngine on
RewriteCond %{HTTP:Upgrade} websocket [NC]
RewriteCond %{HTTP:Connection} upgrade [NC]
RewriteRule .* "ws://localhost:9201%{REQUEST_URI}" [P]
#Redireccion de https(443) a 8080 mostrar maintenace.html en caso de error
ProxyPass /maintenance.html !
ProxyPass / http://localhost:8080/
ProxyPassReverse / http://localhost:8080/
#Archivos de bitacora
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
#Configuracion de SSL
SSLEngine on
SSLCertificateFile "CERTFILE"
SSLCertificateKeyFile "KEYFILE"
</VirtualHost>
@LaszloMorzsa
Copy link

Thanks! It helps a lot!

@MrAkaki
Copy link
Author

MrAkaki commented Sep 4, 2018

For use this conf, first enable mod_proxy, mod_proxy_http and mod_proxy_wstunnel
a2enmod proxy
a2enmod proxy_http
a2enmod proxy_wstunnel

@moondec
Copy link

moondec commented Sep 27, 2019

Thx. I lost all day with it.

@andreafalco1991
Copy link

Thanks it helps me too!

@ombra32
Copy link

ombra32 commented Jan 24, 2022

Very useful to put Thingsboard behind a proxy with https/ssl connection.
I appended this to my 000-default-le-ssl.conf , after Certbot section:

        ProxyRequests Off
        ProxyPreserveHost On
        # wss -> ws redirect
        RewriteEngine on
        RewriteCond "%{HTTP:Upgrade}" "websocket" [NC]
        RewriteCond "%{HTTP:Connection}" "upgrade" [NC]
        RewriteRule "^/?(.*)" "ws://localhost:8080/$1" [P,L]
        # https -> http(8080) redirect
        ProxyPass "/" "http://localhost:8080/"
        ProxyPassReverse "/" "http://localhost:8080/"

Many many thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment