1

I maintain a web application at work hosted on a cloud platform.

I was hoping to use this kind of workflow.

  1. While the live site is running, prepare a new environment identical to the production environment, just with new code running on it.
  2. Test for a while and if it's found to be good, switch production over to the new server, but keep the old one around.
  3. If the client encounters a problem, the idea is to quickly switch back to the original servers.
  4. If the new servers are good, eventually delete the old ones, and start the process over next time we deploy.

There are multiple server instances involved, configured in complicated ways, but they are all front-ended by an application/webserver. So switching would only involve pointing to a new front end server.

What would be the best way to achieve this?

I was thinking of using HAProxy, but all the examples are about failover or load balancing, I just really want to use it as a manual 'switch' to quickly switch between servers.

I'd also like for the proxy to do SSL termination and it has to deal with websockets.

5
  • Wouldn't changing your DNS be sufficient? (you'd have to set the cache to a very small amount like 1 minute) Jun 17, 2017 at 22:32
  • 2
    A loadbalancer and/or a reverse proxy would indeed be a quick way to switch from one backend server to another with minimal effort and downtime.
    – HBruijn
    Jun 17, 2017 at 22:41
  • 2
    @AlexisWilke DNS is a very poor option, as you have little to no real control over it. Putting a load balancer in front is by far the best option.
    – EEAA
    Jun 17, 2017 at 23:08
  • 1
    As @HBruijn said, a load balancer and/or reverse proxy would be ideal. Also, having one front-end you can set each environment under its own subdomain, and keep all running alongside. Then, you just choose which one would receive canonical traffic, or people accessing without a subdomain. I have done that with nginx and now I use Caddyserver which makes easy to switch to HTTP/2 and use Let's Encrypt for SSL.
    – Pablo
    Jun 18, 2017 at 2:17
  • @EEAA You have a similar issue with a load balancer, if a request has been sent computer A, it has to drain before computer A gets taken down. The DNS is a bit more blurry, I agree, but that's a cheap solution. Now, thinking about it, if there is only ONE front end, as Pablo mentioned, you can do that with Apache, Nginx, etc. by creating a proxy. Probably way easier than HAProxy. Jun 18, 2017 at 3:14

1 Answer 1

0

You can use Apache as a reverse proxy. It does SSL termination and can also proxy websockets from version 2.4 and up.

In the easiest version (without any load balancing since you said traffic is "all front-ended by an application/webserver") you just add use this configuration:

ProxyPass "/"  "http://server_IP/"
ProxyPassReverse "/"  "http://server_IP/"

To change your destination you just change the IPs to point to the other server and reload apache.

More information can be found here:

https://httpd.apache.org/docs/2.4/howto/reverse_proxy.html

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .