i have a multiple domains on my centos vps (domains running on apache http server via virtual host configurations). and also same vps, i want to add my new domain but that domain will route my spring boot application (application is a jar file also inside embedded tomcat ). i couldn't find any configuration for embedded tomcat specific domains and ports.
standalone Tomcat i can make configuration via server.xml file like this image
also this short tutorial shows configuration for stadalone tomcat Tomcat Virtual Host Configuration
But how can i do that configuration for embedded Tomcat ? Any suggestion ?
With Spring Boot embedded Tomcat, you are hosting only one application per servlet container. So I don't believe that Tomcat's concept of Virtual Hosts make sense at all.
If you have to host your app on shared Tomcat instance, just build WAR without embedded container.
It depends. 2 ways to deploy your project.jar as you want to :
First way : You can use the "apache web server" and his own "mod_proxy" in order to serve as many Spring webapps you want to, each on a specific port configured with "php-fpm" and with a proxy defined to route requests from/to your namebased VirtualHost configuration.
Nowadays, with Spring Boot 2.5, all you have to do is to set the property server.port in your application.properties file, and use it accordingly with mod_proxy directives.
If you are using profile, you can either set one port to dev or prod or test or whatever properties file you need.
Another way to proceed : you can use the apache web server "mod_jk" bridge module to configure multiple load-balancers for your Virtualhosts too.
Choose your path, young Jedi ;)
This response is certainly not for the OP, 7 years later, but for other people whom are using any web search engine like Google. They will come here and see "something is impossible". It is not true.
Related
I have created Spring boot application and Angular project (Angular 1) separately. In my local i am using npm to server the client app and it calls my back end app services. I am using Embedded tomcat in spring boot application.
Now i want to host my application in server. How do i do that?
Can i have embedded tomcat and build as jar or should i have to install standalone tomcat in the server and deploy my application as war?
How to configure my client code for example, in godaddy i have given ip xx.xx.xx.xx to www.xyz.com. The ip address is my production cloud server. How to redirect to angular application and that application calls server exposed apis.
I cannot have single application that has client code. I should do with two different application only. Please help me deploying this in best way. If embedded tomcat doesnt help then i can install standalone tomcat in server and and build my app as war and deploy it.
The current best practice would be to embed the servlet container (Tomcat, Jetty, other) into the artifact and build a fat JAR. The main advantage is a simplified deployment process: it's enough to push the far JAR into environment and execute it. Unlike the usual servlet container with WAR deployment model the embedded approach doesn't have to deal with additional configuration layers e.g. thread pools or data sources shared between different WARs.
One example of how to build a far JAR with embedded servlet container is spring-boot-starter-web dependency with spring-boot-maven-plugin:repackage goal. In this setup to build a fat JAR it's enough to run mvn clean package repackage.
If you are developing locally your web client code most likely will face issues with the same-origin policy. You most likely will need a CORS filter, however it's provided by Tomcat.
I'm using Arquillian to deploy a Java EE WAR on Payara embedded for functional testing with Graphene. Everything works fine.
However, I'd like to know whether it's possible to test user authentication for #RolesAllowed protected RESTful methods. Afaik there's no way around creating users on the Java EE server and in GlassFish and Payara that's done in the web admin UI:
I didn't find anything about a Payara RESTful or similar API for Payara admin tasks.
There seems to be nothing created on the filesystem by the drone driver so that there's no access to the asadmin command.
According to sudo netstat -tupln | grep java the Payara embedded process only opens port 8181 (HTTP) and 8182 (can't be opened in browser).
My question is similar to How to test login with Arquillian - Java EE 7 whose answer doesn't work because CommandRunner isn't injected and a comment says the interface has changed - whatever that means.
The approach in Embedded Glassfish, security and Arquillian questions doesn't work because it's unclear which Server class is used and none of the available ones match all method names (I tried all that pop up in NetBeans autocompletion).
I'm aware of the possbility to replace the embedded with a remote instance, but that's not part of the question.
I'm using Payara 4.1.2.174.
The preferred way to configure the embedded GlassFish/Payara is to configure a standalone Payara Server instance interactivey first (using Admin console or asadmin commands), copy the configuration from the domain (domain1) into test resources and then point the Arquillian container to the configuration.
The documentation of the Arquillian GlassFish embedded container describes that you can use the property instanceRoot to point to the whole domain directory or configurationXml to just point to the domain.xml in that directory.
In fact, the answer in your last link (https://stackoverflow.com/a/24967309/784594) explains precisely this scenarios and provides a ste-by-step guide. You shouldn't be using any Server class to configure the server, you can skip that step - if you secure your REST endpoint using basic HTTP authentication, you just need to send user and password in request headers.
I have created a project using JHipster (Spring Boot) and bundled it with a .war file. The application is working fine when deployed to AWS EC2 instance.
Now the management wants me to deploy it on AWS Elastic Beanstalk and move all the configurations outside the .war file. For instance, The DB connection, email configuration, PayPal configuration not to be bundled with the .war file, whereas, it should load the properties from external resource like S3.
Can someone please help how can I change the application.yml and application-dev.yml etc to load values from some external source?
Take a look to Spring Cloud Config, which is initially meant to be used on spring cloud microservices, but can be used in order to solve your problem.
The approach here is, that in the early boot up phase your application connects to a spring cloud config server, to get external configuration. More on this, you can change several config properties, while your deployed application is running.
For the storage, cloud config enables git for production use case to store your configs, and I am pretty sure you can somehow use S3 for this...if needed.
I have a application where running with tomcat 8, I am using spring security, so its impossible to access a file where not in my tomcat 8.
For example, my application with tomcat 8 can open with http://domain.com, then I have a directory where located at /root/image.
But my tomcat location in /root/tomcat8/webapp/ROOT.war.
I tried to use symbolic link and open the folder /root/image as allmyimage
but when I try to open that image with http://domain.com/allmyimage/nature.jpg, my application with spring security will handle this one and not allow me to access /root/image/nature.jpg.
Then I try to use nginx, but I don't know what to configure, and I don't know if nginx will resolve my problem.
Any suggestion?
My system is divided to 2 or 3 servers architecture, and only one server has a webApp
Since we use javaMelody to monitor the webApp server, is there a way to use on a regular, no-
webApp JVM, and if so, how can we access the data
I would say include your application into a webapp (a war file for example) then deploy it in a server like Tomcat or Jetty. By the way, Tomcat or Jetty can be embedded.
Otherwise, there is currently no way to do this.