Deploying gradle spring application on a 1and1 cloud server - spring

I have an apache/2.4.18 ubuntu server and I want to host my spring application on it. I generated a JAR file and can run it on the server. It starts an embedded tomcat server on port 8090.
However when i navigate to 'my-site-ip:8090' the connection times out.
I have zero experience deploying web applications so any help would be appreciated.
I've created a TCP rule for port 8090 and still no joy.
The solution was adding a proxy to the Myapp.conf file as below:
ProxyRequests off
ProxyPreserveHost On
ProxyPass / http://localhost:8090/
ProxyPassReverse / http://localhost:8090/
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

It´s very hard to explain all the steps in one answer but you can follow these steps to get into the full configuration by your own. I did the same on my 1&1 cloud server.
First of all you need root access to your server.
Normally, on your server the port 80 and 443 should already be open. Else you can define that in the 1&1 Admin Portal. If your Server already has the apache configuration you should be able to see the apache site if you go to your server address. You can find details and the full setup if you dont have an apache installed for this step here:
How To Install the Apache Web Server on Ubuntu
The second step would be to configure a virtual host on your apache webserver.
This is cool because you can define multiple domains and there applications on your server. So http://yourServer.com(port 80 or 443 from extern) goes to yourApp1. (port 8090 from intern).
In this step you will tell apache if your enter your url to go to your app with port 8090
How To Set Up Apache Virtual Hosts on Ubuntu
The last step would be to install your spring-boot app as a service on your machine. The docs of Spring describes it very well.
Installation as an init.d Service
If you install the app as a service you are able to start and stop the app with the service command.
service myapp start
And dont forget to add the plugin for maven or gradle to your pom.xml. This is necessary to run the app as a service.
If you follow these Steps you should be able to reach you app without specify a port and be ready to go with your app in production if necessary.

The best approach for this would be to use the apache proxy. This should get it done.
https://blog.marcnuri.com/running-apache-tomcat-and-apache-httpd-on-port-80-simultaneously/

Related

Windows 10 Magento Local Installation with XAMP problem with Virtual Hosts

I have installed Magento in my personal laptop with XAMP (windows 10) all looks good. Followed the same steps on another laptop and not able to get Magento running.
Found that port 80 is occupied in the new laptop and configured xamp with port 8090, Apache, Phymyadmin and all works good. Following is my configuration for virtual hosts file
<VirtualHost *:8090>
DocumentRoot "C:/M/xampp8.1/htdocs/magento2/pub"
ServerName kumar.magento245.com
</VirtualHost>
<VirtualHost *:8090>
DocumentRoot "C:/M/xampp8.1/htdocs"
ServerName localhost:8090
</VirtualHost>
Following in windows hosts file
127.0.0.1:8090 kumar.magento245.com
XAMP Apache running on port 8090
when i enter kumar.magento245.com gives 404 error
I assure you the rest of the installation is in sync with my earlier laptop (that dont have any service running on port 80 and i dint changed the hosts file)
Kindly please advise what to be done..
Not planning to change/edit the service running on port 80 .
when i enter kumar.magento245.com gives 404 error.. it should got my local magento running ( installed at C:/M/xampp8.1/htdocs/magento2/pub )
I followed a response in the following thread #Raz0rwire and solved my issue.
Set up virtual hosts on Apache (XAMPP, Windows 10)
accessed the url like this kumar.magento245.com:8090 port number at the end..
Welcome to SO #kumar2023,
There could be multiple possibilities for resolving this issue,
in this case, I would prefer the below steps :
Try running Magento with the direct browser URL ie. https://yourmagnetopath/pub and ensure at least my Magento has been installed
correctly
Try removing the default ports and their entries, in my case well I am using ubuntu hence there could be a case of caching if you tried multiple times with the same URL.
Try with the incognito browser or I would prefer a new browser where you haven't tried to run this URL.
Just give a try with the newer domain (again there could be a reason for caching)

How to enable port 80 or 443 for Spring Boot app deployed with BoxFuse

Spring Boot app is configured (default) to run Tomcat on port 8080. This application gets deployed on AWS via BoxFuse tool and exposed at port 8080 (as expected/configured).
I have tried setting server port to 80 in boot application properties but it causes permission denied issue and the solution seems to be modifying iptables or reverse proxy. ipTables modification is not possible due to boxFuse image/env not being editable.
Question: Is there a way in BoxFuse to setup the spring boot application on port 80 without actually setting up another instance for reverse proxy? It is an overhead to setup an instance just for port correction since can't change the iptables.
Also, Is it possible that this application is run with root privileges on the AWS instance so that I do not need to modify iptables or set up reverse proxy?
There is a -ports.Name option available when deploying the application with BoxFuse.
Docs: https://cloudcaptain.sh/docs/gradle/run
Example:
boxfuse -ports.http=80 -env=test run myapprepo/myapp:0.1
Verified on local dev environment. For Mac, it should be run as a privileged command via sudo
sudo boxfuse -ports.http=80 run myapprepo/myapp:0.1
To add, works for 443 too.

Tomcat 7 - Ubuntu : create a domain name instead of IP:8080/appName

I have deployed my webapp on an Ubuntu server in my company.
the war is in the folder :
/var/lib/tomcat7/webapps
Tomcat7 has deployed the archive in the folder
/var/lib/tomcat7/webapps/bioApp/
My problem is that to access the web app I need to type the url :
http://IP_OF_SERVER:8080/bioApp
I would like the users to type :
www.bioApp.com
I have tried many solutions (modifying server.xml, hosts file, etc).
None of them work.
If anyone has a working solution...
Thanks
The first thing you need is a local dns server in your company. In your dns server add a rule to route your ip (IP_OF_SERVER) to the local domain name
IP_OF_SERVER bioApp.com
If you had an apache server, you must add a virtualhost in your conf file (See this page for more information)
<VirtualHost *:80>
ServerName bioApp.com
ProxyPass / http://IP_OF_SERVER:8080/bioApp
ProxyPassReverse / http://IP_OF_SERVER:8080/bioAppr
</VirtualHost>
If you don't have a apache server, you can change your tomcat listen port.(See this post).

sonar 3.6 https configuration

I have just upgraded from Sonar 3.2.1 to Sonar 3.6. I was able to configure Sonar 3.2.1 to use https by placing a jetty.xml file in SONAR_HOME. The same approach does not seem to work for Sonar 3.6 and from looking at the source for org.sonar.application.JettyEmbedder I think the https port is hard-coded to 8443. FYI, The embedded jetty version is 7.6.11.
The relevant Sonar FAQ reads thus :
Can SonarQube run in HTTPS mode
No. But you can run SonarQube in a standard HTTPS infrastructure using reverse proxy (in this case the reverse proxy must be configured to set the value 'X_FORWARDED_PROTO: https' in each HTTP request header. Without this property, redirection initiated by the SonarQube server will fall back on HTTP).
If this is true then Sonar has taken a step backwards security-wise. Is there an alternative way to configure Sonar/Jetty to run on https ?
You can install Apache on the same machine and set reverse proxy.
Your http://your-sonar-host.com address needs to run on port 80. Apache will forward it to 9000 (sonar runs on port 9000)
After installing Apache, open the configuration and type the following:
<Location />
ProxyPass http://your-sonar-host.com:9000/
ProxyPassReverse http://your-sonar-host.com:9000/
RequestHeader set X_FORWARDED_PROTO 'https'
SetEnv force-proxy-request-1.0 1
SetEnv proxy-nokeepalive 1
</Location>
There is nothing else you need to do.

Running Apache without explicitly declaring listening on ports such as :3000 or :6600

Using Ruby and Thin as a web service. Apache is also loaded. Can't access the web service because listing ports, such as :3000 or :6600, in the GET url is not allowed. How is the port requirement removed?
Use Apache ProxyPass.
cd /etc/apache2/sites-enabled/
sudo vi 000-default
Edit Lines:
ServerAdmin webmaster#localhost
ProxyPass /breakfast http://localhost:4567/breakfast
DocumentRoot /var/www
sudo /etc/init.d/apache2 restart
If you're talking about Apache HTTPD, either leave off the port, or specify "80" for the port.
If you're talking about Apache Tomcat, you'll need to set up an HTTP Connector with port=80, but Tomcat will need to be launched as root.

Resources