假设 ThingsBoard 以 docker 方式运行,需要通过反向映射来提供服务,为了加强安全性,用 https 和 wss,但是,wss 映射需要注意最后几行配置。

<VirtualHost *>
    DocumentRoot /var/www/iot
    ServerName iot.domain
    RewriteEngine on
    RewriteCond %{SERVER_PORT} !^443$
    RewriteRule ^(.*)$ https://%{SERVER_NAME}$1 [L,R]

    <Directory /var/www/iot>
        allow from all
        Options None
        Require all granted
    </Directory>
</VirtualHost>
<VirtualHost *:443>
    DocumentRoot "/var/www/iot"
    ServerName iot.doamin
    <Directory "/var/www/iot">
    allow from all
    Options FollowSymLinks
    Require all granted
    AllowOverride All 
    </Directory>
    SSLEngine on
    SSLCertificateFile /etc/httpd/conf.d/server.crt
    SSLCertificateKeyFile /etc/httpd/conf.d/server.key
    SSLCertificateChainFile /etc/httpd/conf.d/ca.crt

    ProxyPreserveHost On
    ProxyPass / http://127.0.0.1:8088/
    ProxyPassReverse / http://127.0.0.1:8088/
    ProxyPass /api/ws ws://127.0.0.1:8088/
    ProxyPassReverse /api/ws ws://127.0.0.1:8088/

    RewriteEngine on
    RewriteCond %{HTTP:Upgrade} =websocket [NC]
    RewriteRule /(.*) ws://127.0.0.1:8088/$1 [P,L]
</VirtualHost>

标签: none

添加新评论