Skip to content

Instantly share code, notes, and snippets.

@CoderInOne
Last active May 15, 2019 04:06
Show Gist options
  • Save CoderInOne/3b16b6188f5638ac86685b1558102b38 to your computer and use it in GitHub Desktop.
Save CoderInOne/3b16b6188f5638ac86685b1558102b38 to your computer and use it in GitHub Desktop.
notes on nginx
# proxy cache
# cache store specified as keys_zone, 10m is size limit
proxy_cache_path /usr/local/etc/nginx/cache-api levels=1 keys_zone=cache-api:10m;
# upstream http module
upstream foo {
server 127.0.0.1:8093 weight=2 max_fails=3 fail_timeout=10s;
server 127.0.0.1:8094 weight=2 max_fails=3 fail_timeout=10s;
# ...
}
server {
listen 8081;
location / {
proxy_pass http://foo;
real_ip_header 127.0.0.1/44443;
}
# cache...
location /cache {
proxy_pass http://foo;
proxy_cache cache-api;
proxy_cache_valid 200 10s;
}
# proxy map location to http
location /foo/ {
proxy_pass http://foo;
}
# deny
location = /deny/index {deny all;}
}
server {
listen 80 default_server;
server_name www.example.com;
location / {
# which dir files locating in
root /usr/share/nginx/html;
# alias /usr/share/nginx/html;
index index.html index.htm;
}
}
@CoderInOne
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment