昨天,今天,明天,每天的每天,你是否都多懂得一点点...

星期四, 七月 12, 2018

Nginx Proxy as Load Balancer


I would like to put away azure file storage and use dropbox to host my website files.

I found it much faster to load my website when using local files. (because azure files are access from Samba).

A great thing I found is that I don't even need to stop my old docker container to start my new docker container. 

Because my world press docker container is behind nginx proxy, the only thing I need to do is starting a new docker container with the same  VIRTUAL_HOST name.

sudo docker run -d --name wp4 \
  --network wp-net --network-alias wp4-host \
    -e VIRTUAL_HOST=www.dengnz.com \
    -e "LETSENCRYPT_HOST=www.dengnz.com" \
    -e "LETSENCRYPT_EMAIL=email@email.com" \
     -v $PWD/html:/var/www/html -p 8083:80 wordpress 

​Now, nginx proxy will work as a load balance, some traffics are redirected to my old docker container (using azure file). And some traffic will be redirected to my new container (using local files).

There will be two ip addresses in the upstream section of the config file
/etc/nginx/conf.d# cat default.conf



well, only one left now, as I stopped the old one.

​As my new container is working well. Then I safely stopped my old container. 

Website migrated smoothly.


--
Feng

没有评论:

其它博客地址

此博客的同步博客地址: http://fengnz.wordpress.com
这里进入我的MSN SPACE.