Hi,
I m using Nginx as Load balancer with ngx_http_memcached_module and I installed a Memcached Server that I would like to connect it with Nginx to make it obtain responses from a Memcached server.
Load balancer.conf (Nginx)
upstream backend {
# least_conn;
server 192.168.222.130 weight=1 max_fails=3 fail_timeout=30s;
server 192.168.222.131 weight=2 max_fails=3 fail_timeout=30s;
}
proxy_buffer_size 1k;
proxy_buffers 24 4k;
proxy_cache_path /var/lib/nginx/cache levels=1:2 keys_zone=backcache:8m max_size=50m;
proxy_cache_key "$scheme$request_method$host$request_uri$is_args$args";
proxy_cache_valid 200 302 10m;
proxy_cache_valid 404 1m;
server {
listen 80;
location / {
proxy_cache backcache;
proxy_cache_bypass $http_cache_control;
add_header X-Proxy-Cache $upstream_cache_status;
proxy_pass http://backend;
}
location /wp-admin {
proxy_pass http://192.168.222.130/wp-login.php;
}
}
Memcached Conf:
PORT="11211"
USER="memcached"
MAXCONN="1024"
CACHESIZE="64"
OPTIONS="192.168.222.139"
Nginx Example Configuration from the official website
But I don’t understand what each ligne is doing and can’t apply it to my server.
server {
location / {
set $memcached_key "$uri?$args";
memcached_pass host:11211;
error_page 404 502 504 = @fallback;
}
location @fallback {
proxy_pass http://backend;
}
}