- WildFly Cookbook
- Luigi Fugaro
- 481字
- 2021-07-16 13:38:14
Binding WildFly onto a custom port
Why would you bind WildFly onto a custom port? This is because you might have a different service running on the same IP:PORT (that is, another WildFly or JBoss instance, Tomcat, or GlassFish).
How to do it...
Just open your command line and launch your WildFly standalone instance as follows:
$ cd $WILDFLY_HOME $ ./bin/standalone.sh
Now you can change the port using either the Web Console or the CLI:
Using the Web Console
- Point your browser to the following address:
http://127.0.0.1:8080/console
. - Log in by entering the credentials specified in Chapter 1, Welcome to WildFly! while adding the management user; we entered
wildfly
as the username andcookbook.2015
as the password. - Select the Configuration tab and select from the menu on the left side under general configuration, the voice Socket Binding, and select View as shown in the following screenshot:
- Select the
http
property and scroll down the page to edit the port number, as shown in the following screenshot: - Now, change the port number from
8080
to9080
and click on the button labeled Save. You will be notified, but the GUI will denote that the update was successful and that a server reload is required to take advantage of the new changes. - Go to the Runtime tab. You should see a button labeled Reload, click on it and confirm, as shown in the following screenshot:
- Now open your Web Console using the new port number as follows:
http://localhost:9080/console
.
Using the CLI
In a different terminal, connect to the CLI and do as follows:
$ ./bin/jboss-cli.sh
You are disconnected at the moment; type connect
to connect to the server or help
for the list of supported commands:
[disconnected /] connect [standalone@localhost:9990 /] /socket-binding-group=standard-sockets/socket-binding=http:read-attribute(name=port) { "outcome" => "success", "result" => expression "${jboss.http.port:8080}" } [standalone@localhost:9990 /] /socket-binding-group=standard-sockets/socket-binding=http:read-attribute(name=bound-port) { "outcome" => "success", "result" => 8080 } [standalone@localhost:9990 /] /socket-binding-group=standard-sockets/socket-binding=http:write-attribute(name=port,value=9080) { "outcome" => "success", "response-headers" => { "operation-requires-reload" => true, "process-state" => "reload-required" } } [standalone@localhost:9990 /] reload [standalone@localhost:9990 /] /socket-binding-group=standard-sockets/socket-binding=http:read-attribute(name=port) { "outcome" => "success", "result" => 9080 } [standalone@localhost:9990 /]
There's more…
Actually there is another method to change the port number, which is by passing standalone.sh
, a Java parameter (which starts with a capital "D") as follows:
$ cd $WILDFLY_HOME $ ./bin/standalone.sh -Djboss.http.port=9080
This will match the property named http
specified in the socket-binding
tag, for the attribute port
in standalone.xml
.
Note
If you are coming from JBoss AS 5 or 6, you might have used port-offset
, which still changes the port number by adding the offset to the default value (which is 8080
), but also changes other port numbers. In WildFly, it would also change the management port.
So we specify the port-offset to 1000
as follows :
$ ./bin/standalone.sh -Djboss.socket.binding.port-offset=1000
We would end up with WildFly listening on port 9080 (that is, 8080+1000) and the WildFly management port would be 10990 (that is, 9090+1000).
- Java Web應(yīng)用開(kāi)發(fā)技術(shù)與案例教程(第2版)
- 面向?qū)ο蟪绦蛟O(shè)計(jì)(Java版)
- 網(wǎng)絡(luò)爬蟲(chóng)原理與實(shí)踐:基于C#語(yǔ)言
- Modern JavaScript Applications
- The Professional ScrumMaster’s Handbook
- Python網(wǎng)絡(luò)爬蟲(chóng)技術(shù)與應(yīng)用
- Android Studio Cookbook
- 深入理解BootLoader
- Flask Web開(kāi)發(fā):基于Python的Web應(yīng)用開(kāi)發(fā)實(shí)戰(zhàn)(第2版)
- 游戲設(shè)計(jì)的底層邏輯
- Mastering Machine Learning with R
- Spring Microservices
- 狼書(shū)(卷2):Node.js Web應(yīng)用開(kāi)發(fā)
- Instant OpenCV for iOS
- Scratch少兒編程思維訓(xùn)練:培養(yǎng)孩子的邏輯思維和計(jì)算思維能力