Motadata Docs

How to Change the Port of Nginx and Main Server?

Main Server (Tomcat)

To change the default port (8080) of Main Server, follow the steps below:

For example: If you want to change the default port from 8080 to 8082,

Step 1: Go to the Main-Server Config folder using the below path:

/opt/flotomate/main-server/config/application-custom.properties

Enter the following command:

cd /opt/flotomate/main-server/config/

Step 2: Edit and save the below properties key by using the below format:

Key: server.port=YOURPORTNUMBER

For Example: server.port=8082

OR

You can also use the below command if you are not familiar with vi, vim, and nano.

Command:

echo "server.port=YOURPORTNUMBER" >> application-custom.properties

For example:
echo "server.port=8082" >> application-custom.properties

Note: If you change the port, also change and update it in the Nginx config file.

Step 3: In the Nginx config file, replace the old port with the new one using the below command:

cd /etc/nginx/conf.d

sed -i 's/old-port/new-port/g' fmtuser.conf

For example:
sed -i ‘s/8080/8082/g’ fmt_nginx.conf

Step 4: Once done, check whether the port is updated on fmt_nginx.conf file.

Step 5: Next, restart the main-server and Nginx services to replicate the changes using the below commands:

systemctl stop ft-main-server
systemctl stop ft-analytics-server
systemctl restart nginx

Nginx Server

To change the port of the Nginx server,

Step 1: Edit and save the nginx config file to update the port number. You can find the config file from the below path:

/etc/nginx/conf.d

By default, the Nginx server runs on port 80 and 443.

Step 2: To change the port, kindly edit the file as per your port number.

For example:

If you run nginx on port 8080(HTTP) and 8443 (HTTPS), edit the ports as shown below:

listen [::]:8080;

listen 8443 ssl;

listen [::]:8443 ssl;

Step 3: Once done, save the config file, and restart the Nginx service using the below command.

systemctl restart nginx

The ServiceOps URLs will appear as shown below:

For example:

HTTP URL: http://dummy.com:8080/

HTTPS URL: https://dummy.com:8443/

URL

The allowed port commands are:

ufw allow 8080
ufw allow 8443

Note: Before updating, kindly take the backup of the config file.