官术网_书友最值得收藏!

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
  1. Point your browser to the following address: http://127.0.0.1:8080/console.
  2. Log in by entering the credentials specified in Chapter 1, Welcome to WildFly! while adding the management user; we entered wildfly as the username and cookbook.2015 as the password.
  3. 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:
  4. Select the http property and scroll down the page to edit the port number, as shown in the following screenshot:
  5. Now, change the port number from 8080 to 9080 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.
  6. Go to the Runtime tab. You should see a button labeled Reload, click on it and confirm, as shown in the following screenshot:
  7. 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).

主站蜘蛛池模板: 北宁市| 桐柏县| 育儿| 原阳县| 河池市| 定安县| 尤溪县| 鱼台县| 阿拉善左旗| 清流县| 金华市| 苏尼特右旗| 义乌市| 稻城县| 武穴市| 张北县| 莱芜市| 托克托县| 三原县| 永泰县| 广灵县| 余干县| 林芝县| 福贡县| 新疆| 鹤岗市| 怀集县| 四川省| 浠水县| 洛阳市| 新乡市| 东城区| 二手房| 印江| 织金县| 陈巴尔虎旗| 博罗县| 策勒县| 江油市| 甘孜县| 丰原市|