Created
June 27, 2020 01:44
-
-
Save cmendesce/cc69e97204b297a6ed85e61988057c31 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| version: '3' | |
| services: | |
| nginx: | |
| image: nginx | |
| ports: | |
| - 80:80 | |
| volumes: | |
| - ./nginx.conf:/etc/nginx/nginx.conf | |
| - wordpress:/usr/share/nginx/html | |
| wordpress1: | |
| image: wordpress:5.4.2-php7.2-apache | |
| restart: always | |
| environment: | |
| WORDPRESS_DB_HOST: db | |
| WORDPRESS_DB_USER: exampleuser | |
| WORDPRESS_DB_PASSWORD: examplepass | |
| WORDPRESS_DB_NAME: exampledb | |
| volumes: | |
| - ./wordpress:/var/www/html | |
| wordpress2: | |
| image: wordpress:5.4.2-php7.2-apache | |
| restart: always | |
| environment: | |
| WORDPRESS_DB_HOST: db | |
| WORDPRESS_DB_USER: exampleuser | |
| WORDPRESS_DB_PASSWORD: examplepass | |
| WORDPRESS_DB_NAME: exampledb | |
| volumes: | |
| - ./wordpress:/var/www/html | |
| wordpress3: | |
| image: wordpress:5.4.2-php7.2-apache | |
| restart: always | |
| environment: | |
| WORDPRESS_DB_HOST: db | |
| WORDPRESS_DB_USER: exampleuser | |
| WORDPRESS_DB_PASSWORD: examplepass | |
| WORDPRESS_DB_NAME: exampledb | |
| volumes: | |
| - ./wordpress:/var/www/html | |
| db: | |
| image: mysql:5.7 | |
| restart: always | |
| environment: | |
| MYSQL_DATABASE: exampledb | |
| MYSQL_USER: exampleuser | |
| MYSQL_PASSWORD: examplepass | |
| MYSQL_RANDOM_ROOT_PASSWORD: '1' | |
| volumes: | |
| - db:/var/lib/mysql | |
| volumes: | |
| wordpress: | |
| db: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| events { worker_connections 1024; } | |
| http { | |
| upstream wordpress { # configura um pool de endereço de servidores | |
| server wordpress1; | |
| server wordpress2; | |
| server wordpress3; | |
| } | |
| server { # configura esse servidor | |
| listen 80 default_server; # escutando por conexões na porta 80 | |
| listen [::]:80 default_server; | |
| root /usr/share/nginx/html; | |
| index index.php; | |
| location / { # repassa todos os requests para um dos endereços do upstream | |
| proxy_pass http://wordpress; # esse endereço aponta para o upstream wordpress | |
| add_header X-Upstream $upstream_addr; # adiciona o header Host com o valor de um dos endereços configurados no upstream | |
| proxy_set_header Host $host; | |
| proxy_set_header X-Real-IP $remote_addr; | |
| proxy_set_header x-forwarded-for $proxy_add_x_forwarded_for; | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment