1
socket.io电话我不深的Apache配置使 后++小时的谷歌和实验,并开始紧张起来,我需要帮助concering是所有请求我使用端口80的“站点名称”始终以重定向到node.js socket.io服务器脚本结束。apache httpd的-vhosts.conf谁重定向只能从端口80
从浏览器我请求为index.htm应做socket.io东西。
如何配置httpd-vhosts.conf允许使用端口80调用php/js/html/..(除index.htm)“site-name”不被重定向到node.js?
(XAMPP)的Apache/2.4.25(Win32的)的OpenSSL/1.0.2j PHP/30年6月5日
的httpd-vhosts.conf看起来像这样
<VirtualHost *:80>
ServerName site-name
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/socket.io [NC]
RewriteCond %{QUERY_STRING} transport=websocket [NC]
RewriteRule /(.*) ws://localhost:8088/$1 [P,L]
ProxyPass http://localhost:8088/
ProxyPassReverse http://localhost:8088/
</VirtualHost>
的index.htm:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Socket.io</title>
</head>
<body>
<h1>Communication with socket.io!</h1>
<script src="http://site-name/socket.io/socket.io.js"></script> <script>
var socket = io();
console.log("socketId: " + socket.id);
socket.on('news', function (data) {
console.log(data);
socket.emit('my other event', { my: 'client-data' });
});
感谢的对你有所帮助 圭多