Skip to main content

How to Change the Port of Main and Nginx Server?

Customize your ServiceOps deployment and avoid port conflicts by learning how to change the default ports for the main application and Nginx servers.

ServiceOps uses default ports for its main server (Tomcat) and Nginx web server. The main server typically runs on port 8080, while Nginx serves HTTP on port 80 and HTTPS on port 443. This guide provides step-by-step instructions for changing these default ports to accommodate custom deployment requirements, network configurations, or security policies.

Changing ports may be necessary when:

  • Port conflicts with other applications
  • Security requirements mandate non-standard ports
  • Load balancer configurations require specific ports
  • Network policies restrict standard ports
  • Multiple ServiceOps instances on the same server

Prerequisites

Before changing ports, ensure you have:

  • Administrative access to the ServiceOps server
  • Backup of current configuration files
  • Understanding of network requirements and port availability
  • Service status knowledge - verify which services are currently running
  • Firewall configuration access for new port rules

Main Server (Tomcat) Port Change

The main server runs on Tomcat and handles core ServiceOps application logic. By default, it uses port 8080.

Step 1: Backup Current Configuration

  1. Create backup of current configuration:

    cp /opt/flotomate/main-server/config/application-custom.properties /opt/flotomate/main-server/config/application-custom.properties.backup
  2. Verify backup creation:

    ls -la /opt/flotomate/main-server/config/application-custom.properties*

Step 2: Navigate to Configuration Directory

  1. Access the main server config folder:

    cd /opt/flotomate/main-server/config/
  2. Verify current configuration:

    cat application-custom.properties

Step 3: Configure New Port

Option A: Using Text Editor

  1. Edit the configuration file:

    vi application-custom.properties
    # or
    nano application-custom.properties
  2. Add or modify the port configuration:

    server.port=YOUR_PORT_NUMBER

    Example: To change to port 8082:

    server.port=8082

Option B: Using Command Line

  1. Add port configuration using echo:

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

    Example: To change to port 8082:

    echo "server.port=8082" >> application-custom.properties
  2. Verify the configuration:

    cat application-custom.properties

Step 4: Restart Services

  1. Stop the main server service:

    systemctl stop ft-main-server
  2. Stop the analytics server service:

    systemctl stop ft-analytics-server
  3. Restart Nginx service:

    systemctl restart nginx
  4. Start the main server service:

    systemctl start ft-main-server
  5. Start the analytics server service:

    systemctl start ft-analytics-server

Step 5: Verify Port Change

  1. Check if the service is listening on the new port:

    netstat -tlnp | grep :8082
    # or
    ss -tlnp | grep :8082
  2. Test connectivity to the new port:

    curl -I http://localhost:8082

Nginx Server Port Change

Nginx serves as the web server and reverse proxy for ServiceOps. By default, it runs on port 80 (HTTP) and 443 (HTTPS).

Step 1: Backup Nginx Configuration

  1. Create backup of current Nginx configuration:

    cp /etc/nginx/conf.d/fmt_nginx.conf /etc/nginx/conf.d/fmt_nginx.conf.backup
  2. Verify backup creation:

    ls -la /etc/nginx/conf.d/fmt_nginx.conf*

Step 2: Locate Nginx Configuration

  1. Navigate to Nginx configuration directory:

    cd /etc/nginx/conf.d/
  2. List configuration files:

    ls -la *.conf

Step 3: Edit Nginx Configuration

  1. Open the main Nginx configuration file:

    vi fmt_nginx.conf
    # or
    nano fmt_nginx.conf
  2. Locate the server block that contains the listen directives

  3. Modify the port numbers as needed:

    For HTTP port change (default: 80):

    server {
    listen 8080;
    listen [::]:8080;
    # ... other configuration
    }

    For HTTPS port change (default: 443):

    server {
    listen 8443 ssl;
    listen [::]:8443 ssl;
    # ... SSL configuration
    }

    Complete example for both HTTP and HTTPS:

    server {
    listen 8080;
    listen [::]:8080;
    server_name your-domain.com;

    # ... other HTTP configuration
    }

    server {
    listen 8443 ssl;
    listen [::]:8443 ssl;
    server_name your-domain.com;

    ssl_certificate /etc/ssl/your-cert.crt;
    ssl_certificate_key /etc/ssl/your-key.key;

    # ... other HTTPS configuration
    }

    Once done, save the config file.

Step 4: Test Nginx Configuration

  1. Validate Nginx configuration syntax:

    nginx -t
  2. Check for configuration errors:

    nginx -T | grep -E "(listen|server_name)"

Step 5: Restart Nginx Service

  1. Restart Nginx to apply changes:

    systemctl restart nginx
  2. Verify Nginx is running:

    systemctl status nginx
  3. Check if Nginx is listening on new ports:

    netstat -tlnp | grep nginx
    # or
    ss -tlnp | grep nginx

Firewall Configuration

After changing ports, update firewall rules to allow traffic on the new ports.

Ubuntu/Debian (ufw)

  1. Allow new HTTP port:

    ufw allow 8080
  2. Allow new HTTPS port:

    ufw allow 8443
  3. Verify firewall rules:

    ufw status numbered

CentOS/RHEL (firewalld)

  1. Allow new HTTP port:

    firewall-cmd --permanent --add-port=8080/tcp
  2. Allow new HTTPS port:

    firewall-cmd --permanent --add-port=8443/tcp
  3. Reload firewall rules:

    firewall-cmd --reload
  4. Verify firewall rules:

    firewall-cmd --list-ports

URL Configuration

After changing ports, update ServiceOps URLs to reflect the new port configuration.

Example URLs

HTTP URLs:

  • Before: http://your-domain.com/
  • After: http://your-domain.com:8080/

HTTPS URLs:

  • Before: https://your-domain.com/
  • After: https://your-domain.com:8443/

Update ServiceOps Configuration

  1. Access ServiceOps Admin Console using the new URL
  2. Navigate to Admin > Organization > System Preference > Application Settings.
  3. Update Base URL to reflect the new port configuration.
  4. Save configuration changes.

Verification and Testing

Step 1: Test Service Connectivity

  1. Test main server connectivity:

    curl -I http://localhost:8082
  2. Test Nginx HTTP connectivity:

    curl -I http://localhost:8080
  3. Test Nginx HTTPS connectivity:

    curl -I https://localhost:8443

Step 2: Verify Application Functionality

  1. Access ServiceOps through web browser using new URLs
  2. Test login functionality
  3. Verify all modules are accessible:
    • Incident Management
    • Service Request Management
    • Asset Management
    • Change Management
  4. Check file upload/download functionality
  5. Test API endpoints if applicable

Step 3: Monitor Service Logs

  1. Check main server logs:

    tail -f /opt/flotomate/main-server/logs/application.log
  2. Check Nginx logs:

    tail -f /var/log/nginx/access.log
    tail -f /var/log/nginx/error.log

Troubleshooting

Common Issues

Port Already in Use:

# Check what's using the port
netstat -tlnp | grep :8082
lsof -i :8082

# Kill process if necessary
kill -9 <PID>

Nginx Configuration Errors:

# Test configuration
nginx -t

# Check syntax
nginx -T

# View error logs
tail -f /var/log/nginx/error.log

Service Start Failures:

# Check service status
systemctl status ft-main-server
systemctl status nginx

# View service logs
journalctl -u ft-main-server -f
journalctl -u nginx -f

Firewall Issues:

# Check firewall status
ufw status
# or
firewall-cmd --state

# Test port connectivity
telnet localhost 8082

Rollback Procedure

If issues occur, you can rollback to the original configuration:

  1. Restore main server configuration:

    cp /opt/flotomate/main-server/config/application-custom.properties.backup /opt/flotomate/main-server/config/application-custom.properties
  2. Restore Nginx configuration:

    cp /etc/nginx/conf.d/fmt_nginx.conf.backup /etc/nginx/conf.d/fmt_nginx.conf
  3. Restart services:

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

Best Practices

Before Port Change

  • Document current configuration and port assignments
  • Verify port availability and check for conflicts
  • Plan maintenance window to minimize user impact
  • Test port changes in non-production environment first

During Port Change

  • Follow proper service restart order (stop main server, restart nginx, start main server)
  • Monitor service logs during restart process
  • Test connectivity after each configuration change
  • Keep backup files for quick rollback if needed

After Port Change

  • Update documentation with new port assignments
  • Notify users of new URL configurations
  • Update monitoring tools to use new ports
  • Test all functionality thoroughly
  • Monitor performance to ensure no degradation

Next Steps

After successfully changing ports:

  1. Update network documentation with new port assignments
  2. Configure monitoring tools to use new ports
  3. Update load balancer configurations if applicable
  4. Test disaster recovery procedures with new port configuration
  5. Schedule regular port availability monitoring

[!NOTE] Important: Always backup configuration files before making changes and test port changes in a non-production environment first.