The Nautilus devops team got some requirements related to some Apache config changes. They need to setup some redirects for some URLs. There might be some more changes need to be done. Below you can find more details regarding that:
1.) httpd is already installed on app server 2. Configure Apache to listen on port 8086.
-
Configure Apache to add some redirects as mentioned below:
a.) Redirecthttp://stapp02.stratos.xfusioncorp.com:<Port>/tohttp://www.stapp02.stratos.xfusioncorp.com:<Port>/i.enon wwwtowww. This must be a permanent redirect i.e301b.) Redirect
http://www.stapp02.stratos.xfusioncorp.com:<Port>/blog/tohttp://www.stapp02.stratos.xfusioncorp.com:<Port>/news/. This must be a temporary redirect i.e302.
đ Challenge Requirements
- Apache (
httpd) is already installed on Application Server 2 (stapp02). Configure Apache to listen on port 8086. - Configure Apache redirects:
-
(a)
http://stapp02.stratos.xfusioncorp.com:<Port>/âhttp://www.stapp02.stratos.xfusioncorp.com:<Port>/â permanent (301) -
(b)
http://www.stapp02.stratos.xfusioncorp.com:<Port>/blog/âhttp://www.stapp02.stratos.xfusioncorp.com:<Port>/news/â temporary (302)
-
(a)
Step 1: Log in to the Application Server
From the jump host, SSH into stapp02 as steve:
# Login: user=steve | password=Am3ric@ | host=stapp02 (10.244.240.188)
ssh steve@stapp02
Output:
thor@jump-host ~$ ssh steve@stapp02
The authenticity of host 'stapp02 (10.244.240.188)' can't be established.
ED25519 key fingerprint is SHA256:gMtlah5U16R7LS+tjKpYIKMtAq1K14tnySASEzl7FoY.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added 'stapp02' (ED25519) to the list of known hosts.
steve@stapp02's password:
[steve@stapp02 ~]$
Step 2: Switch to root
All configuration changes require root privileges:
# Login: user=steve | password=Am3ric@ | sudo to root (same password)
sudo -i
Output:
[steve@stapp02 ~]$ sudo -i
We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:
#1) Respect the privacy of others.
#2) Think before you type.
#3) With great power comes great responsibility.
[sudo] password for steve:
[root@stapp02 ~]#
Step 3: Configure Apache to listen on port 8086
Edit the main Apache configuration file:
# Login: root@stapp02 | Edit: change "Listen 80" â "Listen 8086"
vi /etc/httpd/conf/httpd.conf
Verify the change:
# Login: root@stapp02 | Verify the Listen directive
grep ^Listen /etc/httpd/conf/httpd.conf
Output:
Listen 8086
â Requirement 1 complete â Apache is now configured to listen on port 8086.
Step 4: (Optional) Allow the new port in SELinux
If SELinux is enforcing, you would normally allow the port with semanage. In this lab, the tool isn't installed â but it turns out not to be needed, since traffic reaches Apache successfully (proven later by curl):
# Login: root@stapp02 | Allow port 8086 in SELinux (not installed in this lab)
semanage port -a -t http_port_t -p tcp 8086
Output:
-bash: semanage: command not found
đĄ Note: No problem â the lab environment doesn't block port 8086 via SELinux, so we can proceed.
Step 5: Create the redirect configuration file
Create a new virtual host config in /etc/httpd/conf.d/:
# Login: root@stapp02 | Create the redirect virtual host config
vi /etc/httpd/conf.d/redirect.conf
Contents:
<VirtualHost *:8086>
ServerName stapp02.stratos.xfusioncorp.com
Redirect 301 / http://www.stapp02.stratos.xfusioncorp.com:8086/
</VirtualHost>
<VirtualHost *:8086>
ServerName www.stapp02.stratos.xfusioncorp.com
Redirect 302 /blog/ http://www.stapp02.stratos.xfusioncorp.com:8086/news/
</VirtualHost>
đĄ Why two VirtualHosts? The
Redirect 301 / ...rule matches all paths. Splitting the rules into separateVirtualHostblocks (keyed byServerName) ensures the/blog/â/news/rule applies only to thewwwhost, without conflicting.
Step 6: Test the configuration syntax
Before restarting, validate the config:
# Login: root@stapp02 | Validate Apache config syntax
httpd -t
Output:
AH00558: httpd: Could not reliably determine the server's fully qualified domain name,
using 10.244.240.188. Set the 'ServerName' directive globally to suppress this message
Syntax OK
âšī¸
AH00558is just a warning, not an error.Syntax OKconfirms the configuration is valid.
Step 7: Restart the Apache service
Apply the changes:
# Login: root@stapp02 | Restart Apache to apply changes
systemctl restart httpd
(No output on success.)
Step 8: Verify the redirects with curl
Test (a): non-www â www (301 permanent)
# Login: root@stapp02 | Test non-www â www redirect
curl -I http://stapp02.stratos.xfusioncorp.com:8086/
Output:
HTTP/1.1 301 Moved Permanently
Date: Wed, 25 Nov 2026 07:03:38 GMT
Server: Apache/2.4.62 (CentOS Stream)
Location: http://www.stapp02.stratos.xfusioncorp.com:8086/
Content-Type: text/html; charset=iso-8859-1
â 301 Moved Permanently returned â requirement 2(a) complete.
Test (b): /blog/ â /news/ (302 temporary)
# Login: root@stapp02 | Test /blog/ â /news/ redirect
curl -I http://www.stapp02.stratos.xfusioncorp.com:8086/blog/
Output:
HTTP/1.1 302 Found
Date: Wed, 25 Nov 2026 07:03:48 GMT
Server: Apache/2.4.62 (CentOS Stream)
Location: http://www.stapp02.stratos.xfusioncorp.com:8086/news/
Content-Type: text/html; charset=iso-8859-1
â 302 Found returned â requirement 2(b) complete.
Step 9: Ensure Apache starts on boot (optional but recommended)
Check whether the service is enabled:
# Login: root@stapp02 | Check if Apache starts on boot
systemctl is-enabled httpd
Output:
disabled
Since it was disabled, enable it:
# Login: root@stapp02 | Enable Apache to start on boot
systemctl enable httpd
Output:
Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service
â /usr/lib/systemd/system/httpd.service.
â Apache will now start automatically on reboot.
â Final Summary
| Requirement | Result | Proof |
|---|---|---|
| Apache listens on port 8086 | â Done |
Listen 8086 in httpd.conf
|
| 301 redirect: non-www â www | â Done | HTTP/1.1 301 Moved Permanently |
302 redirect: /blog/ â /news/
|
â Done | HTTP/1.1 302 Found |
| Apache enabled on boot | â Done |
systemctl is-enabled â enabled
|
đ Key Takeaways
-
Listendirective controls the port Apache binds to â update it in/etc/httpd/conf/httpd.conf. -
Redirect 301= permanent redirect;Redirect 302= temporary redirect. - Always run
httpd -tbefore restarting to catch config errors. -
AH00558is a harmless warning about the FQDN â not a failure. - The
semanagecommand may not be installed, but it's only needed when SELinux actually blocks the port â always verify with a realcurltest rather than assuming. -
systemctl enable httpdensures the service persists across reboots, which many graders check.
The challenge is now fully complete and ready to submit. đ
Top comments (0)