【发布时间】:2021-10-15 15:23:21
【问题描述】:
我正在尝试让我的网站与 nodejs 后端和 websocket 服务器一起工作
我的网站完全在 https 我的节点后端位于端口 8080 上,而我的 websocket 服务器位于 8080 上 我做了一个这样的虚拟主机
<VirtualHost *:8080>
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/socket.io [NC]
RewriteCond %{QUERY_STRING} transport=websocket [NC]
RewriteRule /(.*) ws://localhost:8080/$1 [P,L]
ProxyPass / http://localhost:8080/
ProxyPassReverse / http://localhost:8080/
</VirtualHost>
<VirtualHost *:80>
ServerName www.example.com
ServerAlias example.com
Redirect permanent / https://example.com/
</VirtualHost>
<VirtualHost *:443>
DocumentRoot /var/www/example.com
ServerName www.example.com
ServerAlias example.com
<Directory /var/www/example.com>
Options -Indexes +FollowSymLinks +MultiViews
AllowOverride All
Allow from all
Require all granted
</Directory>
<Directory /var/www/example.com/wp-content>
Options -Indexes +FollowSymLinks +MultiViews
Require all granted
</Directory>
SSLEngine on
SSLCertificateFile /etc/letsencrypt/live/example.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem
<IfModule mod_headers.c>
Header always set Strict-Transport-Security "max-age=15553000; includeSubDomains; preload"
</IfModule>
ErrorLog /var/log/apache2/error.example.com.log
CustomLog /var/log/apache2/access.example.com.log combined
</VirtualHost>
但是当我尝试继续使用 myip:8080 时,它无法正常工作,并且无法连接到我的 websocket 我做错了什么?
【问题讨论】:
标签: node.js apache websocket backend