This comprehensive guide covers the essential steps for securing hospital servers through proper firewall configuration and cybersecurity practices. Learn how to protect patient data and SIMRS systems from cyber threats with practical implementation.
In today's era of healthcare digitalization, hospitals and other healthcare facilities face increasingly complex cybersecurity challenges. Sensitive patient data, such as electronic medical records (EMR) stored in the Hospital Management Information System (SIMRS), has become a prime target for cybercriminals. A data breach incident can be fatal, not only causing significant financial losses, but also damaging the institution's reputation and, most importantly, endangering patient privacy and trust. Given the continuing global trend of increasing cyberattacks, with the average cost of a data breach in the healthcare sector reaching $10.93 million in 2023 according to the IBM Cost of a Data Breach report, the need for a robust security system is absolute. This article will guide you in depth on how to configure a firewall and implement essential server security practices to protect your hospital's IT infrastructure. We will discuss basic concepts, practical implementation using tools such as UFW and Fail2Ban on the Ubuntu Server 22.04 LTS operating system, and present code examples that you can directly apply. The goal is to provide a solid framework for hospital IT managers, clinic owners, and decision-makers to build an effective and proactive cyber defense, ensuring compliance with regulations such as PMK No. 82 of 2013.
Basic Concepts of Firewalls and Layered Defense for Medical Environments
A firewall is the frontline in a network security system, functioning as a filter for incoming and outgoing data traffic based on a predetermined set of rules. In the context of hospitals, the role of a firewall is crucial to protect SIMRS, medical record database servers, PACS (Picture Archiving and Communication System) servers, as well as BPJS or SatuSehat bridging systems from unauthorized access. There are two main types of firewalls: software-based, which runs on the server itself, and hardware-based, which is a separate device at the network perimeter. For hospital servers, a combination of both is often the best strategy, with a hardware firewall at the perimeter and a software firewall on each server.
An effective cybersecurity approach does not rely on only one layer of defense, but instead uses a defense-in-depth strategy. This means implementing various security controls at various points in the IT infrastructure. For example, in addition to a network-level firewall, each individual server must also have a host firewall. This will ensure that even if the network perimeter is breached, the internal servers remain protected. In addition, an intrusion detection system (IDS) or intrusion prevention system (IPS) must be integrated to monitor suspicious activity in real time. Standards such as HIPAA in the United States or regulation PMK No. 82 of 2013 concerning Hospital Management Information Systems in Indonesia implicitly require the implementation of layered security to protect patient health information, because data breaches can have serious legal consequences.
Understanding the concept of least privilege is also very important. This principle states that every user, program, or process should have the minimum access rights necessary to carry out its function. For example, a web server serving the SIMRS interface should not have direct access to sensitive databases; it must communicate through an authenticated and authorized API. Ports opened on the firewall should be limited as much as possible. Port 80/443 for web, 3306/5432 for databases (only from permitted application servers), and 22 for SSH (with source IP restrictions) are examples of common ports. Opening ports excessively is one of the biggest vulnerabilities often exploited by attackers.
It is also important to separate networks logically. For example, the network for SIMRS must be isolated from the guest network or the administrative office network. This can be achieved with VLANs (Virtual Local Area Networks) or proper subnetting. With this isolation, if one network segment is compromised, the impact can be minimized and will not spread to other critical systems. This configuration requires careful network architecture planning and a deep understanding of data flows in the hospital environment. A study by Verizon in 2022 showed that 82% of data breaches involve a human element, so network segmentation also helps reduce the impact of internal errors.
Implementing a Host Firewall with UFW and Fail2Ban on Ubuntu Server 22.04 LTS
For hospital servers using a Linux-based operating system, especially Ubuntu Server 22.04 LTS, UFW (Uncomplicated Firewall) is an excellent choice for managing a host firewall. UFW provides a simpler interface for iptables, making it easier to configure. Together with Fail2Ban, a framework for preventing brute-force attacks, your server will have a significant layer of security. The basic assumption is that you already have a stable Ubuntu Server 22.04 LTS installation and SSH access with sudo privileges.
The first step is to ensure UFW is installed and active. Usually, UFW is already installed by default on Ubuntu. If not, you can install it with sudo apt update && sudo apt install ufw. After that, enable UFW and set the default policy. The recommended default policy is to deny all incoming connections (deny incoming) and allow all outgoing connections (allow outgoing). This ensures that only the services you explicitly allow can be accessed from outside. The commands are: sudo ufw default deny incoming and sudo ufw default allow outgoing. Make sure to run these commands before enabling UFW so that the default policy is applied.
Next, we need to allow the specific ports required by your SIMRS services. For example, if SIMRS runs on port 443 (HTTPS) for the publicly accessible web interface and the PostgreSQL 16.x database server runs on port 5432, and you need SSH access on port 22, you must open those ports. It is important to restrict SSH access to known IP addresses if possible, for example, the IP of your IT office VPN. Example configuration: sudo ufw allow 22/tcp from 203.0.113.10 (replace with your static IP), sudo ufw allow 443/tcp, and sudo ufw allow 5432/tcp from 192.168.1.0/24 (for access from the application server subnet). After all rules are added, enable UFW with sudo ufw enable and ensure its status is active with sudo ufw status verbose. Always test connectivity after enabling or changing firewall rules.
Fail2Ban is another important tool. It scans server log files (such as SSH logs, Nginx 1.22.x web server logs) for IP addresses showing signs of brute-force attacks, then automatically blocks those IPs using firewall rules. Install Fail2Ban with sudo apt install fail2ban. Basic configuration is done in the file /etc/fail2ban/jail.local. You must first copy jail.conf to jail.local: sudo cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local. Inside jail.local, you can enable protection for SSH, Nginx, Apache, or other services. For example, for SSH, ensure the [sshd] section is enabled (enabled = true). You can also adjust parameters such as bantime (how long an IP is blocked, e.g., 1h for 1 hour) and maxretry (number of failed attempts before blocking, e.g., 3). After configuration, restart the Fail2Ban service with sudo systemctl restart fail2ban.
With UFW and Fail2Ban properly configured, your SIMRS server will be better protected from unauthorized access attempts and brute-force attacks. Remember to regularly review UFW logs (/var/log/ufw.log) and Fail2Ban logs (/var/log/fail2ban.log) to monitor activity and adjust rules if necessary. Security is an ongoing process, not a one-time configuration; active monitoring is crucial.
Example of Advanced UFW and Fail2Ban Configuration for SIMRS Server Security
To provide a more concrete picture, let's look at a more in-depth example of UFW and Fail2Ban configuration, including scenarios for specific services such as web servers (Nginx 1.22.x) and databases (PostgreSQL 16) commonly used in modern SIMRS architectures (for example, with a Laravel 11.x backend and React/Vue.js frontend).
First, we will configure UFW. It is assumed that this server will run Nginx as a reverse proxy or direct web server, and PostgreSQL as the main database. SSH access is only allowed from the hospital's internal network, for example 192.168.5.0/24, or from the IT office VPN IP: 203.0.113.10. Port 80 (HTTP) will be redirected to 443 (HTTPS) automatically, so we will focus on 443. Port 5432 for PostgreSQL will only be opened for application servers in the subnet 192.168.5.0/24.
# Reset UFW to default settings to start from scratch (use with caution on production servers!)sudo ufw --force reset# Set default policy: deny all incoming, allow all outgoingsudo ufw default deny incomingsudo ufw default allow outgoing# Allow SSH from specific IP (example: IT VPN IP)sudo ufw allow from 203.0.113.10 to any port 22 comment 'SSH access from IT office'# Allow HTTPS (port 443) for SIMRS web access from anywheresudo ufw allow 443/tcp comment 'HTTPS access for SIMRS'# Allow HTTP (port 80) if needed, for example for redirect to HTTPSsudo ufw allow 80/tcp comment 'HTTP access for redirect'# Allow PostgreSQL (port 5432) only from internal application server subnetsudo ufw allow from 192.168.5.0/24 to any port 5432 comment 'PostgreSQL access from application server'# Enable UFWsudo ufw enable# Check UFW statussudo ufw status verboseThe code above is a script you can run in your Ubuntu server terminal. Each sudo ufw allow line adds a new rule, and the comment option is very helpful for rule documentation. After running this script, it is very important to test connectivity to your services from allowed locations and ensure all SIMRS functions are accessible correctly. Verify that SSH access from unauthorized IPs is blocked, and that web and database access only work from the specified sources.
Next, let's configure Fail2Ban to protect SSH and Nginx. We will create a custom configuration file in /etc/fail2ban/jail.d/ so as not to overwrite jail.local during system updates. This file will be named simrs-security.conf. Assume your Nginx logs are at /var/log/nginx/access.log and error.log. Make sure these log paths match your Nginx configuration.
# File: /etc/fail2ban/jail.d/simrs-security.conf[sshd]enabled = trueport = sshfilter = sshdlogpath = /var/log/auth.logmaxretry = 3bantime = 1hfindtime = 10mignoreip = 127.0.0.1/8 203.0.113.10 # Add your IT office IP here[nginx-http-auth]enabled = trueport = http,httpsfilter = nginx-http-authlogpath = /var/log/nginx/error.logmaxretry = 5bantime = 30m[nginx-dos]enabled = trueport = http,httpsfilter = nginx-doslogpath = /var/log/nginx/access.logmaxretry = 150findtime = 60sbantime = 10maction = %(action_mwl)s# After creating/modifying this file, restart Fail2Ban# sudo systemctl restart fail2banThe Fail2Ban configuration above enables [sshd] to protect SSH from brute-force. The parameter maxretry = 3 means the IP will be blocked if there are 3 failed login attempts within findtime = 10m (10 minutes). bantime = 1h will block that IP for 1 hour. The [nginx-http-auth] section protects against failed HTTP authentication attempts, while [nginx-dos] is a basic filter to detect light DoS attacks based on too many requests from a single IP in a short time. It is important to adjust bantime and maxretry according to your hospital's needs and risk tolerance. After saving the file, run sudo systemctl restart fail2ban to apply the changes. With a combination of strict UFW and proactive Fail2Ban, your SIMRS server will have much stronger defenses against various types of cyber attacks, significantly reducing the risk of intrusion.
Security Incident Handling and Logging for SIMRS Audit
Even though the firewall and Fail2Ban are configured, security incidents can still occur. Therefore, having a clear incident handling strategy and a robust logging system is crucial. In the context of SIMRS, every access, change to patient data, and suspicious connection attempt must be recorded in detail for audit and digital forensics purposes. Standards such as ISO 27001 and HIPAA (in the US) or PMK No. 82 of 2013 require comprehensive logging of system activity to ensure accountability and a clear audit trail.
Suppose you have a SIMRS integration with the SatuSehat service using FHIR R4. A failed or suspicious patient data transaction must be recorded. The following is an example of a FHIR payload that might be sent, and how the log should record it for forensic and audit purposes.
The following is an illustration of an FHIR R4 payload that records the failure to send patient data to SatuSehat:
{
"resourceType": "OperationOutcome",
"issue": [{
"severity": "error",
"code": "processing",
"diagnostics": "Patient.identifier NIK not found in master index",
"location": ["Patient.identifier[0]"]
}],
"meta": {
"lastUpdated": "2025-01-15T08:42:11+07:00",
"source": "simrs-gateway-01"
}
}That payload must be correlated with server logs (nginx access log, SIMRS application, and database audit trail) using a unique request-id or correlation-id. In this way, the hospital IT team can track who accessed what data, when, from which IP, and what the result was. Store logs for at least 6 years in accordance with electronic medical record regulations, and ensure logs are sent to a separate server (log server) so they cannot be manipulated by an attacker who successfully gains access to the SIMRS server.
Practical Tips: Keeping the SIMRS Server Firewall and Security Effective
The initial configuration is only the starting point. Firewalls and security rules must be maintained like medical equipment: checked periodically, tested, and updated. Audit UFW rules every three months with the command sudo ufw status numbered, then remove rules that are no longer relevant. Many hospitals open ports temporarily for vendors or medical devices, then forget to close them again. Make a list of the ports that are truly needed (usually 443 for SIMRS HTTPS, 22 for SSH with IP restrictions, and internal database ports that are not exposed to the internet), then close the rest.
Apply the principle of least privilege to administrator accounts. Do not use the root account for daily login; use sudo with a separate account, enable SSH key authentication and disable password login. For remote access, require a monitored VPN or jump host. In addition, enable automatic security updates (unattended-upgrades) to patch the kernel and critical packages, because unpatched security vulnerabilities are the most common entry point for ransomware targeting patient data.
Test resilience periodically. Conduct simulated port scans from outside (with management permission), test whether Fail2Ban actually blocks after repeated failed attempts, and verify that logs are sent to the central server. Document every configuration change along with the reason and date. This documentation is very valuable during an ISO 27001 audit or an inspection from the Ministry of Health, because it demonstrates documented security governance, not just ad hoc configuration.
FAQ
Are UFW and Fail2Ban enough to protect a SIMRS server?
Not entirely. Both are important layers of defense, but they are not a single solution. You still need regular patch updates, strong authentication (MFA), data encryption in transit and at rest, network segmentation, and centralized log monitoring. A firewall only regulates traffic; it does not detect vulnerable applications or stolen credentials. Treat security as layered defense.
How long should SIMRS audit logs be retained?
Referring to electronic medical record provisions and security audit practices, retain logs for a minimum of 6 years, or longer if there are internal hospital regulations. Store them on separate media with strict access controls, and ensure their integrity is maintained (for example with hashing or write-once storage) so they cannot be altered after being recorded.
What if the SIMRS vendor asks to open many ports for remote support?
Do not open ports directly to the internet. Provide access through a VPN with time-limited accounts, or use remote sessions that are monitored and recorded. Ask the vendor to explain the ports and protocols that are actually needed, then open them only for as long as necessary and close them again when finished. Record every vendor access session in the audit log.
Does this configuration meet security audit requirements?
A documented UFW and Fail2Ban configuration helps meet some security controls, but audits usually also assess policies, procedures, risk management, staff training, and evidence of continuous monitoring. Use internal audit results to close gaps before an external auditor finds them.
Conclusion
Securing a SIMRS server is not a one-time project, but an ongoing process that combines technical configuration, policy, and operational discipline. With strict UFW, proactive Fail2Ban, tidy audit logging, and planned incident handling, hospitals can protect the confidentiality of patient data while meeting regulatory obligations. Start with small steps: audit your firewall rules today, enable centralized logging, and document every change.
If your hospital's IT team needs assistance in designing a security architecture that meets standards, conducting configuration audits, or drafting incident handling procedures, do not hesitate to consult with experienced cybersecurity experts in the healthcare sector. Protect patient data, maintain public trust, and ensure your SIMRS service remains reliable at all times. Contact us for a consultation session and security assessment of your hospital server now.
This article is part of the knowledge base of Nugroho Setiawan, an IT consultant in Jogja (Yogyakarta). Related solutions: SIMRS (Hospital Information System) BPJS & SatuSehat Integration. Need a free consultation?
Komentar
Belum ada komentar. Jadilah yang pertama!
Saya membantu konsultasi IT, pengembangan aplikasi, dan visualisasi data untuk rumah sakit, klinik, dan bisnis di Yogyakarta (DIY), Magelang, dan sekitarnya.