Varnish vs Nginx configuration added
This commit is contained in:
@ -674,6 +674,7 @@ You may wanna change the default security configuration, so go to `http://localh
|
||||
|
||||
<br>
|
||||
<a name="Use-Redis"></a>
|
||||
|
||||
## Use Redis
|
||||
|
||||
1 - First make sure you run the Redis Container (`redis`) with the `docker-compose up` command.
|
||||
@ -761,12 +762,81 @@ Read the [Laravel official documentation](https://laravel.com/docs/5.7/redis#con
|
||||
```
|
||||
|
||||
|
||||
<br>
|
||||
<a name="Use-Varnish"></a>
|
||||
|
||||
## Use Varnish
|
||||
|
||||
The goal was to proxy request to varnish server using nginx. So only nginx has been configured for Varnish proxy.
|
||||
Nginx is on port 80 or 443. Nginx sends request through varnish server and varnish server sends request back to nginx on port 81 (external port is defined in `VARNISH_BACKEND_PORT`).
|
||||
|
||||
The idea was taken from this [post](https://www.linode.com/docs/websites/varnish/use-varnish-and-nginx-to-serve-wordpress-over-ssl-and-http-on-debian-8/)
|
||||
|
||||
The Varnish configuration was developed and tested for Wordpress only. Probably it works with other systems.
|
||||
|
||||
#### Steps to configure varnish proxy server:
|
||||
1. You have to set domain name for VARNISH_PROXY1_BACKEND_HOST variable.
|
||||
2. If you want to use varnish for different domains, you have to add new configuration section in your env file.
|
||||
```
|
||||
VARNISH_PROXY1_CACHE_SIZE=128m
|
||||
VARNISH_PROXY1_BACKEND_HOST=replace_with_your_domain.name
|
||||
VARNISH_PROXY1_SERVER=SERVER1
|
||||
```
|
||||
3. Then you have to add new config section into docker-compose.yml with related variables:
|
||||
```
|
||||
custom_proxy_name:
|
||||
container_name: custom_proxy_name
|
||||
build: ./varnish
|
||||
expose:
|
||||
- ${VARNISH_PORT}
|
||||
environment:
|
||||
- VARNISH_CONFIG=${VARNISH_CONFIG}
|
||||
- CACHE_SIZE=${VARNISH_PROXY2_CACHE_SIZE}
|
||||
- VARNISHD_PARAMS=${VARNISHD_PARAMS}
|
||||
- VARNISH_PORT=${VARNISH_PORT}
|
||||
- BACKEND_HOST=${VARNISH_PROXY2_BACKEND_HOST}
|
||||
- BACKEND_PORT=${VARNISH_BACKEND_PORT}
|
||||
- VARNISH_SERVER=${VARNISH_PROXY2_SERVER}
|
||||
ports:
|
||||
- "${VARNISH_PORT}:${VARNISH_PORT}"
|
||||
links:
|
||||
- workspace
|
||||
networks:
|
||||
- frontend
|
||||
```
|
||||
4. change your varnish config and add nginx configuration. Example Nginx configuration is here: `nginx/sites/laravel_varnish.conf.example`.
|
||||
5. `varnish/default.vcl` is old varnish configuration, which was used in the previous version. Use `default_wordpress.vcl` instead.
|
||||
|
||||
#### How to run:
|
||||
1. Rename `default_wordpress.vcl` to `default.vcl`
|
||||
2. `docker-compose up -d nginx`
|
||||
3. `docker-compose up -d proxy`
|
||||
|
||||
Keep in mind that varnish server must be built after Nginx cause varnish checks domain affordability.
|
||||
|
||||
#### FAQ:
|
||||
|
||||
1. How to purge cache? <br>
|
||||
run from any cli: <br>`curl -X PURGE https://yourwebsite.com/`.
|
||||
2. How to reload varnish?<br>
|
||||
`docker container exec proxy varnishreload`
|
||||
3. Which varnish commands are allowed?
|
||||
- varnishadm
|
||||
- varnishd
|
||||
- varnishhist
|
||||
- varnishlog
|
||||
- varnishncsa
|
||||
- varnishreload
|
||||
- varnishstat
|
||||
- varnishtest
|
||||
- varnishtop
|
||||
4. How to reload Nginx?<br>
|
||||
`docker exec Nginx nginx -t`<br>
|
||||
`docker exec Nginx nginx -s reload`
|
||||
|
||||
<br>
|
||||
<a name="Use-Mongo"></a>
|
||||
|
||||
## Use Mongo
|
||||
|
||||
1 - First install `mongo` in the Workspace and the PHP-FPM Containers:
|
||||
|
Reference in New Issue
Block a user