Backend multiples apache 2.4 how to sync settings virtualhosts - linux

I have a set of apache 2.4 backend (Ubuntu server) with the same virtualhost and same configurations (the content is accessible through an HTTPS balancer). How could I easily replicate this configuration between all apaches (Ubuntu Server)?
FrontEnd LB (HTTPS) -> backend (HTTP) multiple ubuntu servers LTS apache 2.4

You can use mod_proxy_balancer of apache 2.4: official documentation.
You can look at HaProxy, if you want :
blog article on medium.com
official website of HaProxy
You can use many others like : Nginx, Traefik, Neutrino and gobetween.

Related

Spring boot .jar to digital ocean droplet (Linux Ubuntu) :Web server failed to start. Port 80 was already in use

I have an Digitalocean Droplet (virtual private server) that has Ubuntu 18.04 running on it. I installed Apache Web Server and have my website running on it . It's open to traffic on HTTP port 80. My virtual host is setup at /var/www/MyDomainNameHere/public_html/ and I do have a custom domain name pointing to the IP.
I am trying to deploy/run a executable .jar that contains a Spring boot API. It has some basic GET/POST/DELETE HTTP requests. When I run the jar by
java -jar rest-service.jar
I get this error message
***************************
APPLICATION FAILED TO START
***************************
Description:
Web server failed to start. Port 80 was already in use.
Does this mean the Apache Web Server that is open to Traffic on port 80 on this Digital ocean droplet won't let me run the API jar on the same server (The JAR loads up an Apache Tomcat embedded server, I set it to port 80 based on research)? Do I need to buy another droplet? Or can I maybe change the port number for the spring boot jar to something other than port 80? It's an API, so I need to be able to hit the end points
Yes, Apache Web Server using the port and you change your spring application 80 to any other port and use the reverse proxy in Apache Web server. here is the link to configure the reverse proxy
Apache as a Reverse Proxy with mod_proxy
So I will answer my own question. I googled and searched stackoverflow but most people were using the reverse proxy to direct traffic to their standalone embedded Tomcat server (most of time a Spring Boot app) which wasn't applicable to my situation.
However, I already had a static html website at alpizano.me hosted on Digital Ocean that I wanted to use as my Front-end, and only forward certain HTTP requests to my Spring Boot app, which was a REST API essentially.
So after installing Java and PostgreSQL on my DigitalOcean droplet, I SCP'd my JAR file (running ./mvnw clean package -Dmaven.test.skip=true to create it) to my server to a directory like, /var/myapp.
Then after researching for a few days and trying multiple things, I was able to figure out the combination that would allow me to view my website when navigating to alpizano.me, but still allow me to hit my API endpoints that were running on my server as-well, after I ran my jar via java -jar myapp.jar
So I basically had to set up my .conf file in the /etc/apache2/sites-available dir (I only used 1 virtual host for this project) as:
<VirtualHost *:80>
ServerName yourservername.com
DocumentRoot /var/www/yourservername.com/public_html
ProxyPreserveHost On
ProxyPass /api http://127.0.0.1:8080/
ProxyPassReverse /api http://127.0.0.1:8080/
</VirtualHost>
Notice the /api route for the routing that goes to the embedded Tomcat at port 8080 (you can't use port 80 or it will conflict with Apache Server already listening on port 80), else if it's just / , then it will not allow traffic to base website anymore (alpizano.me), which isn't what I wanted.
This wouldn't be needed if you just had a standalone app that you wanted to route traffic, then you could just use / as your route obviously. I saw other posts talking about forwarding the headers but that didn't seem to make a difference for me and I believe ProxyPreserveHost On takes care of that anyway
Good luck.
References:
https://www.digitalocean.com/community/tutorials/how-to-use-apache-as-a-reverse-proxy-with-mod_proxy-on-ubuntu-16-04

setting up nodejs on sharing host

how setting up nodejs on sharing host?
nodejs and git installed on my host and I access to ssh , but when I want to run my application , apache handle those routes.
I read some article but those said fix with httpd.conf and I don't access to httpd.conf
If you have the proper permissions you can forward all the traffic from port 80 that apache handles to the port that your node app is running. You can find examples on google if you search for keywords like apache, vhosts and reverse proxy.

Error MEM sending STATUS command to <host>, configuration will be reset: MEM: Can't read node

I'm trying to implement Wildfly 8.1.0.Final domain setup, profile full-ha, with 1 master and 2 slaves with load balancing by mod_cluster.
My environment:
1) host master on VPS (DigitalOCean) Ubuntu 14.04 LTS x64, Wildfly 8.1.0.Final and Apache Web Server 2.4.7 with mod_cluster 1.3.1.Alpha3-SNAPSHOT;
2) host slave1 on VPS (DigitalOCean) Ubuntu 14.04 LTS x64 and Wildfly 8.1.0.Final;
3) host slave2 on VPS (DigitalOCean) Ubuntu 14.04 LTS x64 and Wildfly 8.1.0.Final.
I had to compile mod_cluster due incompatibility of version 1.2.6 with Apache Web Server 2.4.7.
I see the following errors:
a) on host master (/var/log/apache2/error.log): "(111)Connection refused: AH00957: ajp: attempt to connect to host_slave1 failed"
b) on host slave1 (/opt/wildfly/domain/configuration/servers/server-one/server.log): "2014-09-18 20:50:55,169 ERROR [org.jboss.modcluster] (UndertowEventHandlerAdapter - 1) MODCLUSTER000042: Error MEM sending STATUS command to host_master, configuration will be reset: MEM: Can't read node"
So the load balancing virtual host with mod_cluster is unable to connect to hosts slave1 and slave2.
How to solve this issue, please?
At first, you could use mod_cluster 1.3.1.Final now that is fully integrated with Apache HTTP Server 2.4.x.
The answer
The problem is definitely in you network/host isolation. It is not enough that your worker node can access the EnableMCPMReceive enabled VirtualHost; your Apache HTTP Server must be able to reach back to the worker.
Take a look at the IP address (hostname) the host_slave1 reported to the Apache HTTP Server and make sure it is possible to contact the host_slave1 on that address:port from the Apache HTTP Server machine.
One may easily verify the status on Mod_cluster maanger console, enabled in a virtual host with:
<Location /mod_cluster_manager>
SetHandler mod_cluster-manager
# This is super sensitive, don't open to the world...
Require ip 127.0.0.1
</Location>
HTH
your Apache HTTP Server must be able to reach back to the worker.
ajping is a small easy to install and use script. Install on the load balancer and invoke:
loadbalancer$ ajping host_slave1:8009
Reply from 172.26.XXX.XXX: 7 bytes in 0.002 seconds
This verifies the load balancer can talk AJP to the node.
Your problem is the JBOSS server could not send data to apache server, indeed apache could not redirect your request to jboss application.
The reason could be anyone, maybe if you specify https the cert is not configured, maybe in your jboss, wilfly the configuration have an error the most simple is to follow the exemple on modcluster website or to send standalone or domain.xml and apache configuration.
I think since 2 years he have found the solution, he should post here for person in the futur with same problem...

Redirect a url to a local server

Is there any way to redirect a url to a local server?
Like http://example.com/1.js to http://localhost/1.js, without changing hosts file, using node js.
To configure apache on windows, refer this link proxy on windows
To configure apache on UBUNTU, refer this links
Apache2 reverse proxies
Apache proxy on ubuntu
In below code,
if i visit localhost/http-bind. it will hit localhost:5280/http-bind/
ProxyPass /http-bind http://localhost:5280/http-bind/

Deploying WAR file in Amazon AWS - Tomcat and Apache HTTP Server conflict

I'm using an Amazon Linux AMI instance and I've deployed a war file on it.
The deployed war file shows up in the 'webapps' folder of tomcat6.
The real problem is - Apache HTTP 2.2 server is also installed.
When I access my instance's URL (http://ec2-107-20-92-32.compute-1.amazonaws.com), I see the default page of Apache HTTP 2.2 Only, which, if I'm not wrong, works on port number 80.
Now, how do I get my Apache HTTP 2.2 Server communicate with tomcat6 to display the website deployed in Tomcat?
Or, are there any other alternatives to it?
(I use MacOS X's terminal to connect to my Instance and I uploaded the WAR on S3 to deploy it in tomcat.)
TIA :)
In addition to mac's suggestions (shutting down Apache and making Tomcat listen at port 80, or configuring the Tomcat connector on Apache), you might also set a pair of ProxyPass/ProxyPassReverse directives on your Apache configuration, like the example at mod_proxy documentation.
If you decide to follow this suggestion, your rules would look like follows (in the VirtualHost listening at port 80):
ProxyPass / http://ec2-107-20-92-32.compute-1.amazonaws.com:8080/
ProxyPassReverse / http://ec2-107-20-92-32.compute-1.amazonaws.com:8080/
Nothing worked.
I deleted the instance and tried the same with Ubuntu 12.04 64 bit instance, it worked.
I have no clue why it didnt work in Amazon Linux AMI :(

Resources