How do you put up a maintenance page for AWS when your instances are behind an ELB?

后端 未结 6 1396
滥情空心
滥情空心 2021-01-30 16:32

How do you put up a maintenance page in AWS when you want to deploy new versions of your application behind an ELB? We want to have the ELB route traffic to the maintenance inst

6条回答
  •  醉话见心
    2021-01-30 17:26

    As far as I could see, we were in a situation where the above answers didn't apply or weren't ideal.

    We have a Rails application running the Puma with Ruby 2.3 running on 64bit Amazon Linux/2.9.0 that seems to come with a (classic) ELB.

    So ALB 503 handling wasn't an option.

    We also have a variety hardware clients that I wouldn't trust to always respect DNS TTL, so Route53 is risky.

    What did seem to work nicely is a secondary port on the nginx that comes with the platform.

    I added this as .ebextensions/maintenance.config

    files:
      "/etc/nginx/conf.d/maintenance.conf":
        content: |
          server {
            listen 81;
            server_name _ localhost;
            root /var/app/current/public/maintenance;
          }
    
    container_commands:
      restart_nginx:
        command: service nginx restart
    

    And dropped a copy of https://gist.github.com/pitch-gist/2999707 into public/maintenance/index.html

    Now to set maintenance I just switch my ELB listeners to point to port 81 instead of the default 80. No extra instances, s3 buckets or waiting for clients to fresh DNS.

    Only takes maybe ~15s or so for beanstalk (probably mostly waiting for cloudformation in the back-end) to apply.

提交回复
热议问题