简体   繁体   English

如何在子域上运行socket.io?

[英]How to run socket.io on subdomain?

I am not sure it is actually subdomain or not but '/etc/apache2/sites-available/ooo-default.conf' file contains following code - 我不确定它是否实际上是子域,但是'/etc/apache2/sites-available/ooo-default.conf'文件是否包含以下代码-

<VirtualHost *:80>
RewriteEngine on
RewriteCond %{SERVER_NAME} =app.mydomain.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>

My project is kept under '/var/www/html/beta' directory , there is no 'app' directory presented at '/var/www/html' 我的项目保存在“ / var / www / html / beta”目录下,在“ / var / www / html”下没有“ app”目录

How can I run socket io here? 我如何在这里运行io? My server is - Linux Ubuntu 16.04 我的服务器是-Linux Ubuntu 16.04

I find following solution - 我发现以下解决方案-

<VirtualHost *:80>
    ServerName app.mydomain.com

    <Location "/">
        ProxyPreserveHost On
        ProxyPass http://localhost:3000/
        ProxyPassReverse http://localhost:3000/
    </Location>
</VirtualHost>

But it is not working, when I add this codes in '/etc/apache2/sites-available/ooo-default.conf' file , apache2 stops working. 但是它不起作用,当我在“ /etc/apache2/sites-available/ooo-default.conf”文件中添加此代码时,apache2停止工作。 Please help. 请帮忙。

Using the following steps: 使用以下步骤:

1) Update virtual file:- 1)更新虚拟文件:

 <VirtualHost *:80>
    ServerAdmin admin@test.com
    ServerName mysite.com
    ServerAlias www.mysite.com
  ProxyRequests Off Order deny,allow Allow from all
 <Location />
        ProxyPass http:// mysite.com:8000/
        ProxyPassReverse http:// mysite.com:8000/
    </Location>

</VirtualHost>

2) Enabling Necessary Apache Modules 2)启用必要的Apache模块

To enable these four modules, execute the following commands in succession. 要启用这四个模块,请连续执行以下命令。

sudo a2enmod proxy

sudo a2enmod proxy_http

sudo a2enmod proxy_balancer

sudo a2enmod lbmethod_byrequests

3) To put these changes into effect, restart Apache. 3)要使这些更改生效,请重新启动Apache。

sudo systemctl restart apache2

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM