apache.configuration.conf - siddaram217/Docker-OpenShift GitHub Wiki

Configure Tomcat as HTTPS

https://www.digicert.com/ssl-certificate-installation-tomcat.htm step1 :Generate kyestore file and to server.xml file

<Connector SSLEnabled="true" acceptCount="100" clientAuth="false"
	disableUploadTimeout="true" enableLookups="false" maxThreads="25"
	port="8443" keystoreFile="${PATH}/casserver.keystore" keystorePass="pass@123"
	scheme="https" secure="true" sslProtocol="TLS" />

step 2 :access the tomcat with given port https://localhost:8443/

configure apache2 in ubuntu system :

apache logs path-->/var/log/apache2 for enable/diable any mode/site/conf --->a2en/a2dis

Step1: sudo apt install apache2 1.1 Successfull installation check in dir /etc/apache2 all folders 1.2 Check apache instalation success by start -->sudo service apache2 start -->check in browser by locahost

Step2: enable proxy and proxy_http mods //https://www.digitalocean.com/community/tutorials/how-to-use-apache-http-server-as-reverse-proxy-using-mod_proxy-extension sudo a2enmod proxy sudo a2enmod proxy_http sudo a2enmod proxy_ajp sudo a2enmod rewrite sudo a2enmod deflate sudo a2enmod headers sudo a2enmod proxy_balancer sudo a2enmod proxy_connect sudo a2enmod proxy_html

Step3: sudo gedit sites-enabled/000-default.conf //Configure tomcat url and ports with path <VirtualHost *:80> ProxyPreserveHost On ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined ProxyPass /appname http://172.16.1.147:9090/appname2 ProxyPassReverse /appname http://172.16.1.147:9090/appname2

		ProxyPass / http://172.16.1.147:8080/appname2/
		ProxyPassReverse / http://172.16.1.147:8080/appname2/
	</VirtualHost>
	
	* ProxyPreserveHost --> makes Apache pass the original Host header to the backend server. This is useful, as it makes the backend server aware of the ad	dress used to access the application.
	* ProxyPass --> is the main proxy configuration directive. In this case, it specifies that everything under the root URL (/) should be mapped to the backend server at the given address. For example, if Apache gets a request for /example, it will connect to http://your_backend_server/example and return the response to the original client.
	* ProxyPassReverse --> should have the same configuration as ProxyPass. It tells Apache to modify the 	response headers from backend server. This makes sure that if the backend server returns a location redirect header, the client's browser will be redirected to the proxy address and not the backend server address, which would not work as intended.

Step4: restart apache --> sudo service apache2 restart -->successfull restart check in browser with localhost and path specified http://localhost/ http://localhost/appname2


FOR LOAD BALANCER CONFIGRATION :

	Need to enable following mod
	sudo a2enmod lbmethod_byrequests
	
	<VirtualHost *:80>
	<Proxy balancer://mycluster>
		BalancerMember http://172.16.1.147:8080
		BalancerMember http://172.16.1.147:9090
	</Proxy>

		ProxyPreserveHost On

		ProxyPass / balancer://mycluster/
		ProxyPassReverse / balancer://mycluster/
	</VirtualHost>

FOR SSL CONFIGRATION :

1.Need to enable to following mod
sudo a2enmod ssl
2.Need to implement using slef signed certification	https://www.digitalocean.com/community/tutorials/how-to-create-a-self-signed-ssl-certificate-for-apache-in-ubuntu-16-04
certificates will be generate in /etc/ssl dir

3.Need to add ProxyPass and ProxyPassReverse path in /etc/apache2/sites-enabled/default-ssl.conf file.
4.Set <Context sessionCookiePath="/"> in context.xml of tomcat for resetting the url.
5.set context path as "" in index and login of "/" tomcat  and set "/appname" in "/appname" tomcat
⚠️ **GitHub.com Fallback** ⚠️