Setting custom ports in Whistle is achieved by modifying the configuration file or specifying the port during startup. Below are detailed steps and examples:
1. Specify Port via Command Line
When starting Whistle, you can directly specify the port using the command line. This is a common method, particularly useful for temporary changes to port settings. For example, to set the HTTP and HTTPS proxy ports of Whistle to 8888 and 8899 respectively, execute the following in the command line:
bashw2 start -p 8888 -s 8899
Here, -p specifies the HTTP proxy port, and -s specifies the HTTPS proxy port.
2. Modify the Configuration File
If you frequently start Whistle, you may want to persist custom port settings. This can be done by modifying Whistle's configuration file. The configuration file is typically located in the Whistle installation directory, named config.json or similar.
Modify the file in the following format to set default ports:
json{ "port": 8888, "sslPort": 8899 }
After saving the file, Whistle will automatically use these ports each time it is started.
Example
Assume you are developing a local application requiring frequent restarts, and due to network configuration constraints, you need to change Whistle's port from the default 8899 to 9000. You can accomplish this quickly using the following command:
bashw2 start -p 9000
This way, your local application can be configured to use the proxy on port 9000 without conflicting with other services.
Summary
Depending on your specific use case, choose between command-line parameters or the configuration file to set custom ports for Whistle. The command-line method is convenient for temporary changes and testing, whereas the configuration file is better suited for persistent settings. Both methods can be flexibly applied based on your development and deployment needs.