• Skip to main content
  • Skip to primary sidebar
  • Skip to footer

securitywing

How to Setup a Maintenace Page Message in AWS ALB

by wing

AWS application load balaner supports setting up a custom response for specific domain. If you need a easier method to serve a maintnace message from ALB you need to inject  a new rule with fixed response. The fixed response can be a 5xx status code wtih custom html. To add a custom rule using AWS CLI, you need to have AWS CLI installed with the right permission and need  to create a couple of JSON files such as one for creating a new listener ule and another one to delete the rule when you are done with the website maintenace.

Step 1: create a directory and the following two files:

  • actions-fixed-response.json
  • conditions-pattern.json
 

Add the below code to the  actions-fixed-response.json file. Make sure to update the content of your ALB fixed response message for the maintenace page.

[
    {
        “Type”: “fixed-response”,
        “FixedResponseConfig”: {
            “MessageBody”: “<htlm> <h1>This site is currently under maintenance </h1> </html>”,
            “StatusCode”: “503”,
            “ContentType”: “text/html”
        }
    }
]

 

The contents for the conditions-pattern.json will be as below. Replace the domain name to match your custom domain name.

[
    {
        “Field”: “host-header”,
        “HostHeaderConfig”: {
            “Values”: [
                “*.mywebsite.com”
            ]
        }
    }
]

 

Step 2: take a note of your listener ARN that you need adding the rule to and run the command below:

aws elbv2 create-rule --listener-arn <listener arn>  --priority 5 --conditions file://conditions-pattern.json --actions file://actions-fixed-response.json
 
Note: replace the listener-arn by your ALB listener arn and take a note of the rule arn that you need when deleting the rule.
 

Step 3: to delete the rule you can run the command below.

aws elbv2 delete-rule --rule-arn <rule-arn>
Note: replace the rule-arn by your custom rule that you noted in step 2.
 
To delete the rule via powershell you can query the exsting rule using “–query” and delete the rule as shown
below:

$rulearn = (aws elbv2  describe-rules –listener-arn <listener-arn>  –query Rules[0].RuleArn)
aws elbv2 delete-rule –rule-arn $rulearn
Note: replace the listener-arn by your ALB’s listerner arn

Related posts:

  1. How to Query AWS CloudTrail Logs with Athena
  2. How to Permanently Auto-Mount EFF Volume to EC2 instance using User-Data
  3. How to Enable AWS Cross Account ECR Image Replication
  4. Top 10 Actions to Prevent Cyber Defence Evasion on AWS Cloud

Filed Under: AWS

Primary Sidebar

Please help us sharing

Categories

  • AWS
  • Basics
  • Containers
  • Cryptocurrency
  • Cyber
  • Internet Security and Safety
  • IS Audit
  • IT Security Exams
  • Law & Human Rights
  • Network Security Tips
  • Off Track
  • Social Media Governance
  • Tech Comparisons
  • Tech Stack Suitability
  • Telecom
  • Tutorial

CISSP Sample Test

Take a CISSP Sample Test

CISA Sample Test

CISA IT governance Sample test

Please Follow Us

Contact us for Ads

Go to Contact Form

Search

Footer

Copyrights

Protected by Copyscape Duplicate Content Detection Software

Securitywing.com reserves the copyrights of all of its published articles.No contents of this site is permitted to be published to anywhere else in the Internet.If any contents are found in any other websites, securitywing reserves the rights to file a DMCA complaint. But you have the right to use the link of any relevant article of this site to point from your website if you consider that it might improve the quality of your article.

Tags

audit AWS backup basics browser check cisco cloud computer configuration cyber data database email gmail hsrp ids iis informaiton internet kubernetes linux load balancing malware microsoft network protection redundancy risk router security security tips server social media SSL switch test tools vpn vrrp web webserver website windows wordpress

Copyright © 2010-2025 ·All Rights Reserved · SecurityWing.com