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

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).

主站蜘蛛池模板: 桦南县| 门头沟区| 德钦县| 水城县| 广丰县| 留坝县| 伽师县| 平果县| 澳门| 广西| 山东| 东丰县| 宜丰县| 桐乡市| 临漳县| 普格县| 乐平市| 郴州市| 淮安市| 宁强县| 论坛| 广德县| 黄陵县| 南涧| 大冶市| 潞城市| 莲花县| 柘荣县| 新巴尔虎右旗| 疏附县| 新竹市| 视频| 富蕴县| 马边| 扎鲁特旗| 平和县| 南和县| 四子王旗| 巴彦淖尔市| 新兴县| 津市市|