Question:

The system admins team of xFusionCorp Industries needs to deploy a new application on App Server 3 in Stratos Datacenter. They have some pre-requites to get ready that server for application deployment. Prepare the server as per requirements shared below:

1. Install and configure nginx on App Server 3.

2. On App Server 3 there is a self signed SSL certificate and key present at location /tmp/nautilus.crt and /tmp/nautilus.key. Move them to some appropriate location and deploy the same in Nginx.

3. Create an index.html file with content Welcome! under Nginx document root.

4. For final testing try to access the App Server 3 link (via hostname) from jump host using curl command. For example: curl -Ik https:///.


Solution:

Step 1:

# SSH to App server 3
ssh banner@stapp03

# Install nginx
sudo dnf install nginx -y

Step 2:

# Check for certificate files
 ls -l /tmp
total 24
-rw-r--r-- 1 root root 2170 Dec  4 10:02 nautilus.crt
-rw-r--r-- 1 root root 3267 Dec  4 10:02 nautilus.key
...

# Check the nginx config file to see where are other certificate files placed
cat /etc/nginx/nginx.conf | grep ssl
#        listen       443 ssl http2;
#        listen       [::]:443 ssl http2;
#        ssl_certificate "/etc/pki/nginx/server.crt";
#        ssl_certificate_key "/etc/pki/nginx/private/server.key";
#        ssl_session_cache shared:SSL:1m;
#        ssl_session_timeout  10m;
#        ssl_ciphers PROFILE=SYSTEM;
#        ssl_prefer_server_ciphers on;

# List directory content
ls -l /etc/pki/nginx/private/
ls: cannot access '/etc/pki/nginx/private/': No such file or directory

# Create new directory
sudo mkdir -p /etc/pki/nginx/private/

# Move the public key
sudo mv /tmp/nautilus.crt /etc/pki/nginx/

# Move the private key
sudo mv /tmp/nautilus.key /etc/pki/nginx/private/

# Set permissions only root can read it
sudo chmod 600 /etc/pki/nginx/private/nautilus.key

Step 3:

# Start nginx server
sudo systemctl start nginx

# Check nginx server status
sudo systemctl status nginx
● nginx.service - The nginx HTTP and reverse proxy server
     Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; preset: disabled)
     Active: active (running) since Fri 2026-12-04 10:29:05 UTC; 1s ago
    Process: 16169 ExecStartPre=/usr/bin/rm -f /run/nginx.pid (code=exited, status=0/SUCCESS)
    Process: 16170 ExecStartPre=/usr/sbin/nginx -t (code=exited, status=0/SUCCESS)
    Process: 16177 ExecStart=/usr/sbin/nginx (code=exited, status=0/SUCCESS)
   Main PID: 16184 (nginx)
      Tasks: 17 (limit: 404712)
     Memory: 15.8M
        CPU: 49ms
     CGroup: /system.slice/nginx.service
     ...

# HTTP is working yet (tested and confirmed)
curl https://stapp03
... Default page HTML content

# HTTPS is not working yet (tested and confirmed)
curl -k https://stapp03
curl: (7) Failed to connect to 10.244.247.206 port 443: Connection refused

# Edit the default nginx config and add the following config
sudo nano /etc/nginx/nginx.conf
##########################################################
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log notice;
pid /run/nginx.pid;

events {
    worker_connections 1024;
}

http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    sendfile        on;
    keepalive_timeout  65;

    server {
        listen 80;
        listen [::]:80;
        listen 443 ssl;
        listen [::]:443 ssl;

        server_name localhost;

        # SSL Certificate Paths
        ssl_certificate /etc/pki/nginx/nautilus.crt;
        ssl_certificate_key /etc/pki/nginx/private/nautilus.key;

        # Recommended SSL Settings
        ssl_protocols TLSv1.2 TLSv1.3;
        ssl_session_cache shared:SSL:10m;
        ssl_session_timeout 10m;

        # Website Root (Note: RHEL/CentOS default is /usr/share/nginx/html)
        root /var/www/html;
        index index.html index.htm;

        location / {
            try_files $uri $uri/ =404;
        }
    }
}
##########################################################

# Check config syntax and reload nginx
sudo nginx -t && sudo systemctl reload nginx

# Make a new directory
sudo mkdir -p /var/www/html

# Create our index.html
echo "Welcome!" | sudo tee /var/www/html/index.html

# Exit to jump host
exit

curl http://stapp03
Welcome!

curl -k https://stapp03
Welcome!

By shafdo

Leave a Reply

Your email address will not be published. Required fields are marked *