简体   繁体   中英

How to deploy the java web-application to a remote wildfly server?

How to deploy the java application to a remote wildfly server?

On localhost, the application works fine.

So I have a domain name "http:// mysite.com" which addresses to my VPS host.

Java is already installed and running wildfly. In the Wildfly deployments directory, I put file "mysite.com.war" and run wildfly using the command "./standalone.sh -Djboss.http.port = 80" .

But in the browser "http:// mysite.com" is not available.

The good news is that "http:// mysite.com:8080" displays a standard wildfly screensaver, it means I'm already close and the server is up and the domain name is correct.

On the host is not installed either apache or nginx, only wildfly.

What can I do to get my application launched at "http:// mysite.com"?

Update.

I started the wildfly with the command "./standalone.sh -b 0.0.0.0" and added the WEB-INF / jboss-web.xml file -

 <jboss-web xmlns = "http://www.jboss.com/xml/ns/javaee"    xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance"    xsi: schemaLocation = "       http://www.jboss.com/xml/ns/javaee       http://www.jboss.org/j2ee/schema/jboss-web_5_1.xsd ">    <context-root> / </ context-root> </ jboss-web> 

Now my application is available at "http: mysite.com: 8080", how can I make it available at "http: mysite.com"?

You can't bind to port 80 without running the server as root - which is a massive security issue.

You will need to run apache + mod_proxy, nginx, haproxy, pound or similar; This will listen on port 80 and proxy requests to localhost:8080

Wildfly starts in standalone mode. You need to find wildfly-12.0.0.Final/standalone/configuration/standalone.xml and in the subset of the undertow subscribe domain to the application:

 <subsystem xmlns="urn:jboss:domain:undertow:4.0"> <buffer-cache name="default"/> <server name="default-server"> <http-listener name="default" socket-binding="http" redirect-socket="https" enable-http2="true"/> <https-listener name="https" socket-binding="https" security-realm="ApplicationRealm" enable-http2="true"/> <host name="default-host" alias="localhost"> <location name="/" handler="welcome-content"/> <filter-ref name="server-header"/> <filter-ref name="x-powered-by-header"/> <http-invoker security-realm="ApplicationRealm"/> </host> <host name="mysite.com" alias="www.mysite.com" default-web-module="mysite.com.war" disable-console-redirect="false"/> </server> ... </subsystem> 

Then in the same file, find the interfaces section and fix 127.0.0.1 to your ip-address:

 <interfaces> <interface name="management"> <inet-address value="${jboss.bind.address.management:127.0.0.1}"/> </interface> <interface name="public"> <inet-address value="${jboss.bind.address:151.101.65.69}"/> </interface> </interfaces> 

Finally, in the socket-binding-group section, you can fix the ports used:

 <socket-binding-group name="standard-sockets" default-interface="public" port-offset="${jboss.socket.binding.port-offset:0}"> ... <socket-binding name="http" port="${jboss.http.port:80}"/> <socket-binding name="https" port="${jboss.https.port:443}"/> ... </socket-binding-group> 

now it's enough to run wildfly without parameters, just "./standalone.sh" and our application will be available at mysite.com!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM