Use Apache to proxy Meteor App on port 80

Herewith a dump from what I posted on LinuxQuestions then realised it’s probably a Meteor or at least reactive thing:

I have a Meteor app http://localhost:3000 and an app called OpenKM running at http://localhost:8080
Such apps are difficult to (and shouldn’t be) run on port 80.

So I have apache (apache2) which I’ve used most of my life and I can get the meteor app running from http://localhost by doing this :


ProxyPass / http://localhost:3000/ 
ProxyPassReverse / http://localhost:3000/

But if I change it to this http://localhost/astro by doing this :

ProxyPass /astro http://localhost:3000/
ProxyPassReverse /astro http://localhost:3000/

It stops working

The same goes for OpenKM - but why?

I’ve omitted a great deal of config stuff from here because I genuinely feel it’s irrelevant given the scenario painted above(?)

+++++++++++++++++++

After 5 hours more digging it turns out to be a mangled request due to the redirect from Apache.

If you want to run Meteor behind apache2 then (it does work) so this goes into /etc/apache2/sites-enabled/000-default.conf :

[CODE]<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

 ProxyPreserveHost On
 ProxyRequests Off
 ServerName localhost
 <Location / >
  ProxyPass http://localhost:3000/
  ProxyPassReverse http://localhost:3000/
 </Location>
  #ProxyPass / http://localhost:8080/
  #ProxyPassReverse / http://localhost:8080/
</VirtualHost>[/CODE]

and it works despite this error message in the browser console log :

sockjs-0.3.4.js:1275 WebSocket connection to 'ws://localhost/sockjs/125/sq7vbfp6/websocket' failed: Error during WebSocket handshake: Unexpected response code: 400

So the headers are getting mangled somewhere but I don’t fully understand why at this point. But I will soon and post here.

If I try to add the sub-url [sorry , forgot the terminology here] based proxy (i.e. /astros) then it stops working with this error :

sockjs-0.3.4.js:854 GET http://localhost/sockjs/info?cb=e6bj3cvszb 404 (Not Found)

If you use apache2 (fyi I’m on Linux Mint18.2 and use Ubuntus version of apache) then you also need to do this :

[CODE]a2enmod proxy
a2enmod proxy_http
service apache2 restart[/CODE]

So, not solved yet but getting closer.