Skip to content

Instantly share code, notes, and snippets.

@razzul
Created July 27, 2020 06:29
Show Gist options
  • Save razzul/5d22cea79bf00bf1ff1da0bd3093eace to your computer and use it in GitHub Desktop.
Save razzul/5d22cea79bf00bf1ff1da0bd3093eace to your computer and use it in GitHub Desktop.
apache proxy setup
  • sudo a2enmod proxy

  • sudo a2enmod proxy_http

  • sudo a2enmod proxy_balancer

  • sudo a2enmod lbmethod_byrequests

  • sudo a2enmod proxy_wstunnel

  • sudo service apache2 restart

  • sudo nano /etc/apache2/sites-available/000-default.conf

<VirtualHost *:80>
        ServerName devsocket.saviapp.com

        ProxyRequests Off
        ProxyPreserveHost On
        ProxyVia Full
        <Proxy *>
            Require all granted
        </Proxy>

        <Location />
                RewriteEngine On
                RewriteCond %{HTTP:UPGRADE} ^WebSocket$ [NC]
                RewriteCond %{HTTP:CONNECTION} Upgrade$ [NC]
                RewriteRule .* ws://127.0.0.1:3000%{REQUEST_URI} [P]

                ProxyPass http://127.0.0.1:3000/
                ProxyPassReverse http://127.0.0.1:3000/
        </Location>


        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html/dev-socket
        <Directory "/var/www/html">
                 Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                allow from all
        </Directory>

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
  • cd /var/www/html/dev-socket
  • sudo npm install pm2 -g
  • pm2 start npm -- start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment