502 Proxy Error - MeteorJS on Apache - apache

I am new to Meteor, and I have an existing server that is hosting a few websites (CentOS). I use Apache to serve the sites and wanted to have a Meteor app running on a subdomain.
Here is what I have for the Meteor site in httpd.conf:
<VirtualHost *:80>
ServerName www.subdomain.domain.net
ServerAlias subdomain.domain.net
DocumentRoot /var/www/my_meteor_directory/testapp
ProxyRequests Off
<Proxy *>
Order allow,deny
Allow from all
</Proxy>
ProxyPass / http://127.0.0.1:3000
ProxyPassReverse / http://127.0.0.1:3000
</VirtualHost>
I also have this at the bottom of my httpd.conf file:
<Proxy *>
Allow from 127.0.0.1
</Proxy>
ProxyPreserveHost On
ProxyPassMatch ^/(.+\.cf[cm])(/.*)?$ ajp://localhost:3000/$1$2
I set the app to run on port 3000 and when I try to hit it in the browser (subdomain.domain.net) I get these 502 errors:
Any suggestions?

Try this...
<VirtualHost *:80>
ServerName meteorapp.example.com
ProxyRequests off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
<Location />
ProxyPass http://localhost:8080/
ProxyPassReverse http://localhost:8080/
</Location>
</VirtualHost>
then reload the server

Related

How do I send requests to two processes in Apache2?

I got two servers, a custom Rust server I've created, listening to port 4848, and a Gitea server listening at 3000. I can connect to both of these just fine if I input the IP and port directly, but obviously this is not ideal. How can I direct *.domain.exmaple to the process at 4848, and gitea.domain.example at 3000?
I'm using Ubuntu 22
Thanks!
Finally managed to find a solution. I edited my main configuration file to this
<VirtualHost *:80>
ServerAdmin admin#email
ServerName gitea.domain.example
ProxyPreserveHost On
# setup the proxy
<Proxy *>
Order allow,deny
Allow from all
</Proxy>
ProxyPass / http://localhost:3000/
ProxyPassReverse / http://localhost:3000/
</VirtualHost>
<VirtualHost *:80>
ServerAdmin admin#email
ServerName domain.example
ServerAlias *.domain.example
ProxyPreserveHost On
# setup the proxy
<Proxy *>
Order allow,deny
Allow from all
</Proxy>
ProxyPass / http://localhost:4848/
ProxyPassReverse / http://localhost:4848/
</VirtualHost>

Redirect subdomain to subdomain+folder

I've linked a subdomain to my Tomcat app, but I donĀ“t want to put the name of the folder to access. I've done this using Apache as a proxy.
<VirtualHost *:80>
ServerName domain.example.com.pe
ProxyRequests Off
ProxyPreserveHost On
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass /SSHR http://192.168.10.52:8081/SSHR
ProxyPassReverse /SSHR http://192.168.10.52:8081/SSHR
</VirtualHost>
I've tried with this lines:
ProxyPass / http://192.168.10.52:8081/SSHR/
ProxyPassReverse / http://192.168.10.52:8081/SSHR/
It works, but I've some problems with the Tomcat application. So, what I need is something to redirect from example.domain.com.pe to example.domain.com.pe/SSHR.

Apache http proxy and reverse proxy

I need to define two virtual host that should forward my requests to different web applications.
IP of PC where appache is installed is: 192.168.100.208.
IP of application server where application are installed is: 192.168.100.50
<VirtualHost *:7778>
ServerName 192.168.100.208
ProxyRequests On
ProxyPreserveHost Off
<Proxy *>
Order allow,deny
Allow from all
</Proxy>
ProxyErrorOverride On
ProxyPass / http://192.168.100.50:9081/app1/
ProxyPassReverse / http://192.168.100.50:9081/app1/
<Location>
Order allow,deny
Allow from all
</Location>
and I need to have:
<VirtualHost *:7777>
ServerName 192.168.100.208
ProxyRequests On
ProxyPreserveHost Off
<Proxy *>
Order allow,deny
Allow from all
</Proxy>
ProxyErrorOverride On
ProxyPass / http://192.168.100.50:9081/app2/
ProxyPassReverse / http://192.168.100.50:9081/app2/
<Location>
Order allow,deny
Allow from all
</Location>
So when I type in browser:
192.168.100.208:7778 i should get page from 192.168.100.50:9081/app1
and
192.168.100.208:7777 i should get page from 192.168.100.50:9081/app2
But above is not working. Where is mistake?
Make sure to have the following configured also:
#
# Use name-based virtual hosting.
#
NameVirtualHost *:7778
NameVirtualHost *:7777

How can I setup apache to proxy for two different tomcats on the same server?

I have to have two different tomcats on the same server both to be targeted by different domain names. I was wondering if it is possible for apache to proxy to both. I haven't found any documentation that with explanation to this solution yet.
I have below an example virtual host of the two I have on the server which proxies for the single tomcat instance so far:
<VirtualHost *:80>
ServerName tinderbox.mycompany.com
ProxyRequests Off
ProxyPreserveHost On
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass / http://localhost:8080/
ProxyPassReverse / http://localhost:8080/
</VirtualHost>
Something like
<VirtualHost *:80>
ServerName tinderbox.mycompany.com
ProxyRequests Off
ProxyPreserveHost On
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass / http://localhost:8080/
ProxyPassReverse / http://localhost:8080/
</VirtualHost>
<VirtualHost *:80>
ServerName othername.mycompany.com
ProxyRequests Off
ProxyPreserveHost On
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass / http://localhost:9090/
ProxyPassReverse / http://localhost:9090/
</VirtualHost>
Essentially, repeat the VirtualHost block, change the server name so the block applies to your second domain name and change the target of the ProxyPass to whatever ports the second Tomcat instance is using.

Avoid the conflict on port 80 between nodejs and apache

The goal is to listen on port 80 with nodejs without killing apache.
I have to say my knowledges in network are very basic.
UPDATE
I am trying to use ProxyPass ProxyPassReverse on my local machine but there is something wrong.
Alias /test /media/www-dev/public/test
<Directory /media/www-dev/public/test>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>
ProxyRequests off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
<Location />
ProxyPass /test http://localhost:3000/
ProxyPassReverse /test http://localhost:3000/
</Location>
When i launch http://localhost/test on my browser i get a message Cannot GET /test/, if i stop to listen on the port 3000, then i get 503 Service Temporarily Unavailable my node app is listening on the port 3000.
If if commente the "Proxy" lines, i can reach the URL http://localhost/test again.
Why can i not access the URL http://localhost/test ? Is it because the proxy try to reach http://localhost:3000/ instead following the path of the alias /test ?
Thanks !
you need to create a virtual host in apache for your node app and proxy over the requests.
here is what mine looks like in /etc/apache/sites-available/dogself.com
<VirtualHost 69.164.218.75:80>
ServerName dogself.com
ServerAlias www.dogself.com
DocumentRoot /srv/www/dogself.com/public_html/
ErrorLog /srv/www/dogself.com/logs/error.log
CustomLog /srv/www/dogself.com/logs/access.log combined
ProxyRequests off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
<Location />
ProxyPass http://localhost:3000/
ProxyPassReverse http://localhost:3000/
</Location>
</VirtualHost>
It sounds like you have a lot to research before you can get this working though. start reading docs
Alternative approach for a virtual host would be the following
<VirtualHost *:80>
ServerAdmin info#DOMAIN.com
ServerName DOMAIN.com
ServerAlias www.DOMAIN.com
ProxyRequests off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
<Location />
ProxyPass http://localhost:3000/
ProxyPassReverse http://localhost:3000/
</Location>
</VirtualHost>
To fix the Internal Server ERROR just enable the right apache extension.
sudo a2enmod proxy_http
sudo service apache2 restart