cloud learning
cloud learning

Reputation: 3

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 -

<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'

How can I run socket io here? My server is - 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. Please help.

Upvotes: 0

Views: 852

Answers (1)

Rajeev Gautam
Rajeev Gautam

Reputation: 441

Using the following steps:

1) Update virtual file:-

 <VirtualHost *:80>
    ServerAdmin [email protected]
    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

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.

sudo systemctl restart apache2

Upvotes: 3

Related Questions